/* Textpro's shared design system. Load before tool-specific layout CSS.
 * Keep --theme-color compatible with existing saved color pickers.
 * No automatic dark mode: Notes' saved foreground/background controls are retained.
 * Tool files own canvas, editor, preview and other behavior-specific styles.
 */
:root {
  --theme-color: #1c1a99;
  --tp-font:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --tp-mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --tp-bg: #f7f8fc;
  --tp-surface: #fff;
  --tp-surface-muted: #f0f2f8;
  --tp-text: #202637;
  --tp-muted: #596378;
  --tp-border: #d9deea;
  --tp-on-accent: #fff;
  --tp-accent-soft: #eeedff;
  --tp-danger: #b42332;
  --tp-success: #237548;
  --tp-radius-sm: 6px;
  --tp-radius: 12px;
  --tp-radius-lg: 18px;
  --tp-shadow: 0 2px 12px rgb(25 35 65 / 6%);
  --tp-space-1: 4px;
  --tp-space-2: 8px;
  --tp-space-3: 12px;
  --tp-space-4: 16px;
  --tp-space-5: 20px;
  --tp-space-6: 24px;
  --tp-space-8: 32px;
  /* Compatibility aliases for the newer image/audio tools. */
  --bg: var(--tp-bg);
  --card: var(--tp-surface);
  --text: var(--tp-text);
  --muted: var(--tp-muted);
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  font-family: var(--tp-font);
  background: var(--tp-bg);
  color: var(--tp-text);
}
:where(button, input, textarea, select) {
  font-family: inherit;
}
:where(button, input, select, textarea, summary, a):focus-visible {
  outline: 3px solid var(--theme-color) !important;
  outline-offset: 3px;
}
:where(button) {
  cursor: pointer;
}
:where(button):disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
:where(input, textarea, select) {
  accent-color: var(--theme-color);
  color: var(--tp-text);
}
:where(.tp-tool) button {
  font: inherit;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-sm);
  background: var(--tp-surface);
  color: var(--tp-text);
  padding: var(--tp-space-2) var(--tp-space-3);
}
:where(.tp-tool)
  :is(
    input:not([type]),
    input[type="text"],
    input[type="url"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select
  ) {
  background-color: var(--tp-surface);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-sm);
}
.tp-classic {
  display: flex;
  flex-direction: column;
}
:where(.tp-classic)
  :where(
    #case-container,
    #emoji-container,
    #json-container,
    #editor-container,
    #pomodoro-container,
    #snippet-container,
    #todo-container,
    #completed-list,
    #whiteboard-container,
    .wc-stat,
    .pp-panel,
    .pp-content
  ) {
  background: var(--tp-surface);
  border-radius: var(--tp-radius);
  box-shadow: var(--tp-shadow);
}
:where(.tp-classic)
  :where(
    #case-container,
    #emoji-container,
    #json-container,
    #editor-container,
    #pomodoro-container,
    #snippet-container,
    #whiteboard-container
  ) {
  width: calc(100% - 32px);
  padding: var(--tp-space-5);
}
:where(.tp-classic) #theme-color-picker {
  position: absolute;
  top: 10px;
  right: 10px;
}
:where(.tp-tool) .top {
  padding: var(--tp-space-3) var(--tp-space-5);
  background: var(--theme-color);
  color: var(--tp-on-accent);
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
:where(.tp-tool) .top a {
  color: var(--tp-on-accent);
  text-decoration: none;
}
:where(.tp-tool) .top .sep {
  opacity: 0.6;
  margin: 0 8px;
}
:where(.tp-tool) .card {
  background: var(--tp-surface);
  border-radius: var(--tp-radius);
  padding: var(--tp-space-4);
  box-shadow: var(--tp-shadow);
}
:where(.tp-studio) button {
  border-radius: var(--tp-radius-sm);
  padding: var(--tp-space-2) var(--tp-space-3);
}
:where(.tp-studio) button.active,
:where(.tp-studio) button.primary {
  background: var(--theme-color);
  color: var(--tp-on-accent);
  border-color: var(--theme-color);
}
:where(.tp-studio)
  :is(
    input[type="text"],
    input[type="url"],
    input[type="email"],
    input[type="tel"],
    input[type="number"],
    textarea,
    select
  ) {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
}
:where(.tp-studio) input[type="color"] {
  width: 100%;
  height: 38px;
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-sm);
  padding: 2px;
  background: var(--tp-surface);
}
:where(.tp-studio) input[type="range"] {
  width: 100%;
}
:where(.tp-tool) .content {
  margin-top: 30px;
  line-height: 1.6;
}
:where(.tp-tool) .content h2 {
  font-size: 1.25rem;
  margin-top: 26px;
}
:where(.tp-tool) details {
  background: var(--tp-surface);
  border-radius: var(--tp-radius-sm);
  padding: 10px 14px;
  margin: 8px 0;
}
:where(.tp-tool) summary {
  cursor: pointer;
  font-weight: 600;
}
:where(.tp-tool) .footer {
  text-align: center;
  padding: var(--tp-space-4);
  background: var(--tp-surface);
  color: var(--tp-muted);
  font-size: 14px;
  margin-top: auto;
  border-top: 1px solid var(--tp-border);
  line-height: 1.6;
}
:where(.tp-tool) .footer a {
  color: var(--theme-color);
  text-decoration: none;
  font-weight: 600;
}
:where(.tp-tool) .footer a:hover {
  text-decoration: underline;
}
:where(.tp-tool) a.external::after {
  content: "↗";
  margin-left: 4px;
}
:where(.tp-toast-top) #toast {
  position: fixed;
  top: 40px;
  right: 40px;
  background: rgb(0 0 0 / 80%);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--tp-radius-sm);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 100;
}
/* Notes' paired colors must resolve on body, where its controls set the raw values. */
.tp-notes {
  --default-opacity: 0.4;
  --default-br: var(--tp-radius-sm);
  --default-transition: 0.3s;
  --theme-color-raw: 67, 61, 138;
  --theme-color: rgb(var(--theme-color-raw));
  --theme-bg-raw: 255, 255, 255;
  --theme-bg: rgb(var(--theme-bg-raw));
}
@media (max-width: 480px) {
  :where(.tp-tool) .footer {
    font-size: 12px;
    padding: 8px 10px;
  }
  :where(.tp-toast-top) #toast {
    right: 10px;
    top: 10px;
    font-size: 13px;
  }
}

/* Shared upload / media workspace, used by background remover and transcription. */
:where(.tp-media) .wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
:where(.tp-media) .hero {
  background: var(--card);
  border: 2px dashed #c9c8ef;
  border-radius: 16px;
  padding: 40px 20px;
  text-align: center;
  transition: 0.2s;
}
:where(.tp-media) .hero.over {
  border-color: var(--theme-color);
  background: #eeeefd;
}
:where(.tp-media) .hero.compact {
  padding: 16px;
}
:where(.tp-media) .hero.compact h1 {
  font-size: 1.2rem;
  margin: 0 0 4px;
}
:where(.tp-media) .hero.compact .sub {
  display: none;
}
:where(.tp-media) .hero h1 {
  margin: 0 0 10px;
  font-size: 2rem;
}
:where(.tp-media) .sub {
  color: var(--muted);
  margin: 0 0 20px;
}
:where(.tp-media) .hint {
  color: var(--muted);
  font-size: 0.9rem;
}
:where(.tp-media) .upload-btn {
  display: inline-block;
  background: var(--theme-color);
  color: #fff;
  padding: 14px 30px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1.05rem;
}
:where(.tp-media) #workspace {
  margin-top: 16px;
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}
:where(.tp-media) .toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}
:where(.tp-media) .seg {
  display: inline-flex;
}
:where(.tp-media) .seg button {
  border-radius: 0;
}
:where(.tp-media) .seg button:first-child {
  border-radius: 8px 0 0 8px;
}
:where(.tp-media) .seg button:last-child {
  border-radius: 0 8px 8px 0;
}
:where(.tp-media) .seg button.active,
:where(.tp-media) .bgs button.active {
  background: var(--theme-color);
  color: #fff;
  border-color: var(--theme-color);
}
:where(.tp-media) .brush {
  display: flex;
  align-items: center;
  gap: 8px;
}
:where(.tp-media) .ghost {
  background: transparent;
}
:where(.tp-media) .queue {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  margin-bottom: 10px;
}
:where(.tp-media) .q-item {
  white-space: nowrap;
  font-size: 0.85rem;
  padding: 6px 10px;
}
:where(.tp-media) .q-item.active {
  border-color: var(--theme-color);
  color: var(--theme-color);
  font-weight: 600;
}
:where(.tp-media) .stage {
  position: relative;
  display: flex;
  justify-content: center;
  border-radius: 10px;
  overflow: hidden;
  background: #eee;
  min-height: 200px;
  touch-action: none;
}
:where(.tp-media) .checker {
  background-color: #fff;
  background-image:
    linear-gradient(45deg, #ddd 25%, transparent 25%),
    linear-gradient(-45deg, #ddd 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #ddd 75%),
    linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-size: 20px 20px;
  background-position:
    0 0,
    0 10px,
    10px -10px,
    -10px 0;
}
:where(.tp-media) #view {
  display: block;
  max-width: 100%;
  height: auto;
  cursor: ew-resize;
  touch-action: none;
}
:where(.tp-media) .cursor {
  position: absolute;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px #000;
  border-radius: 50%;
  pointer-events: none;
  display: none;
}
:where(.tp-media) .progress {
  margin: 10px 0;
}
:where(.tp-media) .track {
  height: 6px;
  background: #e5e5f2;
  border-radius: 3px;
  overflow: hidden;
}
:where(.tp-media) .bar {
  height: 100%;
  width: 0;
  background: var(--theme-color);
  transition: width 0.2s;
}
:where(.tp-media) .bar.indet {
  animation: ind 1.2s linear infinite;
  background: linear-gradient(90deg, #e5e5f2, var(--theme-color), #e5e5f2);
  background-size: 200% 100%;
}
@keyframes ind {
  to {
    background-position: -200% 0;
  }
}
:where(.tp-media) .status {
  font-size: 0.9rem;
  color: var(--muted);
  margin-top: 6px;
}
:where(.tp-media) .panel {
  margin-top: 14px;
}
:where(.tp-media) .label {
  font-weight: 600;
  margin-bottom: 6px;
}
:where(.tp-media) .bgs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
:where(.tp-media) .bgs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
:where(.tp-media) .sw {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 1px solid #bbb;
  display: inline-block;
}
:where(.tp-media) .sw.checker {
  background-size: 8px 8px;
  background-position:
    0 0,
    0 4px,
    4px -4px,
    -4px 0;
}
:where(.tp-media) .sw.blur {
  background: linear-gradient(135deg, #9bb, #ccd, #cba);
  filter: blur(1px);
}
:where(.tp-media) .sw.img {
  background: linear-gradient(135deg, #7ad, #fc6);
}
:where(.tp-media) .hidden-input {
  width: 0;
  height: 0;
  opacity: 0;
  padding: 0;
  border: 0;
  position: absolute;
}
:where(.tp-media) .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}
:where(.tp-media) .model-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  font-size: 0.9rem;
}
:where(.tp-media) .model-row select {
  padding: 6px;
  border-radius: 6px;
  max-width: 100%;
}
:where(.tp-media) .muted {
  color: var(--muted);
}
:where(.tp-media) .toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #222;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  opacity: 0;
  transition: 0.3s;
  pointer-events: none;
  z-index: 9;
}
@media (max-width: 600px) {
  :where(.tp-media) .hero h1 {
    font-size: 1.5rem;
  }
  :where(.tp-media) .toolbar {
    gap: 8px;
  }
}

/* Shared shell colors for LaunchPad; its saved background / tile opacity still wins. */
.tp-launchpad header {
  background: var(--theme-color);
  color: var(--tp-on-accent);
  text-shadow: none;
}
.tp-launchpad :is(.add-product, .controls button) {
  background: var(--theme-color);
  color: var(--tp-on-accent);
}
.tp-launchpad :is(.add-product, .controls button):hover,
.tp-launchpad .layout-buttons button.active {
  background: color-mix(in srgb, var(--theme-color), #000 20%);
}
.tp-launchpad .modal-content {
  background: var(--tp-surface);
  color: var(--tp-text);
  border-radius: var(--tp-radius);
  box-shadow: var(--tp-shadow);
}
.tp-notes .footer {
  background: var(--theme-color);
  color: var(--theme-bg);
}
.tp-notes .footer a {
  color: var(--theme-bg);
}

/* Shared classic-tool button skins; per-tool files keep only sizing/layout. */
:where(.tp-classic) #add-snippet-btn,
:where(.tp-classic) #download-btn,
:where(.tp-classic) .action-bar button,
:where(.tp-classic) .btn-primary,
:where(.tp-classic) .download-bar button,
:where(.tp-classic) .modal-content button,
:where(.tp-classic) .portability-buttons button,
:where(.tp-classic) .timer-controls button,
:where(.tp-classic:has(#whiteboard-container)) .toolbar button,
:where(.tp-classic) .wc-actions button {
  background: var(--theme-color);
  color: var(--tp-on-accent);
  border: 0;
  border-radius: var(--tp-radius-sm);
  cursor: pointer;
  transition: background-color 0.2s;
}
:where(.tp-classic) .bg-btn,
:where(.tp-classic) .btn-group button,
:where(.tp-classic) .btn-icon,
:where(.tp-classic) .btn-secondary,
:where(.tp-classic) .size-btn {
  background: var(--tp-surface-muted);
  color: var(--tp-text);
  border: 1px solid var(--tp-border);
  border-radius: var(--tp-radius-sm);
  cursor: pointer;
  transition: background-color 0.2s;
}

/* Match mobile container widths to their existing horizontal margins. */
@media (max-width: 768px) {
  :where(.tp-classic)
    :where(
      #case-container,
      #emoji-container,
      #json-container,
      #editor-container,
      #pomodoro-container,
      #snippet-container,
      #whiteboard-container
    ) {
    width: calc(100% - 20px);
  }
}
@media (max-width: 480px) {
  :where(.tp-classic)
    :where(
      #case-container,
      #emoji-container,
      #json-container,
      #editor-container,
      #pomodoro-container,
      #snippet-container,
      #whiteboard-container
    ) {
    width: calc(100% - 10px);
  }
}
