/* Shared semantic tokens; themes change color, never component layout. */
:root {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color-scheme: light;
  color: var(--text);
  background: var(--canvas);
  --bottom: calc(76px + env(safe-area-inset-bottom));
  --dock-offset: 0px;
  --text: #202d3c;
  --canvas: #e9edf1;
  --app: #f7f8fa;
  --surface: #ffffff;
  --surface-soft: #eceff3;
  --sheet: #f8f9fb;
  --nav: #fffffff2;
  --blue: #245cce;
  --button: #2463eb;
  --on-accent: #ffffff;
  --muted: #626e7c;
  --line: #dfe4eb;
  --focus: #608feb;
  --chip-active: #202f43;
  --chip-text: #ffffff;
  --accent-soft: #edf3ff;
  --chosen: #f2f6ff;
  --chosen-border: #7d9fdb;
  --success: #356e5e;
  --success-soft: #eef7f3;
  --warm: #78623a;
  --warm-soft: #f7f3e8;
  --danger: #a93c3c;
  --track: #e2e8f0;
  --handle: #bdc6d1;
  --switch-off: #c6ced8;
  --shadow: 0 8px 35px #25334b20;
  --backdrop: #16233a65;
  --toast: #23344b;
  --toast-text: #ffffff;
  --tab-active: transparent;
  --glow: 0 0 0 transparent;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --text: #eef0f4;
  --canvas: #0c0e10;
  --app: #141619;
  --surface: #202328;
  --surface-soft: #292d33;
  --sheet: #1b1e23;
  --nav: #1b1e23f5;
  --blue: #93b6ff;
  --button: #a3beff;
  --on-accent: #13233f;
  --muted: #adb5c1;
  --line: #383e47;
  --focus: #b2cdff;
  --chip-active: #a3beff;
  --chip-text: #13233f;
  --accent-soft: #28354c;
  --chosen: #26344a;
  --chosen-border: #789cd9;
  --success: #9dd8bb;
  --success-soft: #243a32;
  --warm: #dcc396;
  --warm-soft: #393328;
  --danger: #ffaaa8;
  --track: #3a414c;
  --handle: #687382;
  --switch-off: #545c69;
  --shadow: 0 8px 35px #0006;
  --backdrop: #0009;
  --toast: #dce5f7;
  --toast-text: #16233a;
  --tab-active: #28354c;
}
:root[data-theme="colorful"] {
  --canvas: #e8e3f3;
  --app: #f6f4fb;
  --surface-soft: #ede8f7;
  --sheet: #faf8ff;
  --nav: #faf8fff5;
  --text: #302544;
  --blue: #7040bf;
  --button: #7644c9;
  --muted: #71647e;
  --line: #e0d7ed;
  --focus: #9664e3;
  --chip-active: #7040bf;
  --accent-soft: #eee4fc;
  --chosen: #f1e9ff;
  --chosen-border: #a27aca;
  --success: #176d64;
  --success-soft: #e2f4ee;
  --warm: #176d64;
  --warm-soft: #e2f4ee;
  --track: #e4d9f2;
  --handle: #b7a6ce;
  --tab-active: #eee4fc;
  --shadow: 0 8px 35px #57347b20;
}
:root[data-theme="magic"] {
  color-scheme: dark;
  --text: #eef0ff;
  --canvas: #080d1c;
  --app: #101628;
  --surface: #1b233c;
  --surface-soft: #232c47;
  --sheet: #171f36;
  --nav: #141c32f5;
  --blue: #b8acff;
  --button: #baafff;
  --on-accent: #221943;
  --muted: #adb6d4;
  --line: #36415f;
  --focus: #77dce8;
  --chip-active: #baafff;
  --chip-text: #221943;
  --accent-soft: #302e52;
  --chosen: #2a2d50;
  --chosen-border: #8c81ce;
  --success: #8ce0d5;
  --success-soft: #1d383f;
  --warm: #98d8ef;
  --warm-soft: #20364c;
  --danger: #ffafc3;
  --track: #354061;
  --handle: #6d739e;
  --switch-off: #505b7b;
  --shadow: 0 -4px 30px #8a76ed12, 0 8px 35px #0005;
  --backdrop: #060b1eb3;
  --toast: #ddd7ff;
  --toast-text: #221943;
  --tab-active: #302e52;
  --glow: 0 0 18px #a090ff22;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
  color: inherit;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button,
a,
input,
select {
  -webkit-tap-highlight-color: transparent;
}
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
button {
  touch-action: manipulation;
}
svg.icon {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.app {
  max-width: 600px;
  margin: auto;
  min-height: 100dvh;
  background: var(--app);
  position: relative;
  padding-top: env(safe-area-inset-top);
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 22px 24px 10px;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -0.4px;
}
.brand-mark {
  background: var(--button);
  color: var(--on-accent);
  width: 26px;
  height: 26px;
  border-radius: 8px;
  text-align: center;
  line-height: 26px;
  font-size: 23px;
}
.demo-label {
  margin-left: auto;
  font-size: 9px;
  letter-spacing: 1.3px;
  font-weight: 600;
  color: var(--muted);
}
main {
  padding: 12px 24px calc(var(--bottom) + 24px);
}
body.has-selection main {
  padding-bottom: calc(var(--bottom) + var(--drawer-height, 56px) + 24px);
}
.heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
h1 {
  font-size: 34px;
  letter-spacing: -1.3px;
  margin: 0;
  line-height: 1.3;
}
h2 {
  font-size: 18px;
  letter-spacing: -0.4px;
  margin: 0;
}
h3 {
  font-size: 15px;
  margin: 0;
}
p {
  line-height: 1.5;
}
.subtitle {
  font-size: 13px;
  color: var(--muted);
  margin: 4px 0 22px;
}
.text-button {
  border: 0;
  background: transparent;
  color: var(--blue);
  font-size: 14px;
  font-weight: 650;
  min-height: 44px;
  padding: 8px 10px;
}
.search {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface-soft);
  border-radius: 12px;
  padding: 0 12px;
  color: var(--muted);
  height: 46px;
}
.search input {
  border: 0;
  outline: none;
  background: none;
  width: 100%;
  min-width: 0;
  color: var(--text);
  font-size: 14px;
  height: 100%;
}
.search:focus-within {
  box-shadow: 0 0 0 2px var(--focus);
}
.filters {
  display: flex;
  gap: 7px;
  margin: 15px 0 12px;
  overflow-x: auto;
  scrollbar-width: none;
}
.chip {
  white-space: nowrap;
  min-height: 44px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 8px 13px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}
.chip.active {
  background: var(--chip-active);
  color: var(--chip-text);
  border-color: var(--chip-active);
}
.library-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding: 0 0 12px;
  margin-bottom: 22px;
}
.library-tools select {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  min-height: 44px;
  max-width: 48%;
}
.library-tools .text-button {
  font-size: 12px;
  padding: 6px;
}
.group-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 23px 0 11px;
}
.group-heading h2 {
  font-size: 15px;
}
.group-heading span {
  color: var(--muted);
  font-size: 11px;
}
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}
.tile {
  position: relative;
  padding: 0;
  border: 0;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--surface-soft);
  border-radius: 5px;
  display: block;
  width: 100%;
}
.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.18s;
}
.tile.selected {
  box-shadow: inset 0 0 0 3px var(--blue);
}
.tile.selected img {
  transform: scale(0.9);
  border-radius: 4px;
}
.check {
  position: absolute;
  right: 7px;
  top: 7px;
  width: 22px;
  height: 22px;
  border: 1.5px solid #fffffff0;
  border-radius: 50%;
  background: #17233425;
  color: white;
  display: grid;
  place-items: center;
}
.selected .check {
  background: var(--button);
  color: var(--on-accent);
  border-color: white;
}
.check .icon {
  width: 14px;
  height: 14px;
}
.duration {
  position: absolute;
  bottom: 7px;
  right: 7px;
  color: white;
  text-shadow: 0 1px 4px #000;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  font-weight: 600;
}
.duration .icon {
  width: 12px;
  height: 12px;
}
.sent {
  position: absolute;
  left: 7px;
  bottom: 7px;
  background: var(--success-soft);
  color: var(--success);
  border-radius: 5px;
  padding: 3px;
  display: flex;
}
.sent .icon {
  width: 12px;
  height: 12px;
}
.library-footer {
  text-align: center;
  color: var(--muted);
  font-size: 11px;
  margin: 25px 0;
}
.library-footer .icon {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  margin-right: 4px;
}
.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  height: var(--bottom);
  background: var(--nav);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  z-index: 5;
}
.tab {
  border: 0;
  background: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-size: 10px;
  font-weight: 600;
}
.tab.active {
  color: var(--blue);
  background: var(--tab-active);
  border-radius: 12px;
}
.tab.active .icon {
  stroke-width: 2;
}
.selection {
  position: fixed;
  bottom: calc(var(--bottom) + var(--dock-offset));
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow);
  z-index: 4;
  max-height: calc(
    100dvh - var(--bottom) - var(--dock-offset) - env(safe-area-inset-top) -
      16px
  );
  overflow-y: auto;
  overscroll-behavior: contain;
}
.drawer-header {
  width: 100%;
  min-height: 56px;
  border: 0;
  background: transparent;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  position: relative;
  text-align: left;
  font-size: 14px;
  touch-action: pan-x;
  user-select: none;
}
.drawer-header > .icon {
  color: var(--blue);
}
.drawer-header:focus-visible {
  outline-offset: -4px;
  border-radius: 16px;
}
.selection-size {
  color: var(--muted);
  font-weight: 400;
}
.drawer-handle {
  display: none;
  position: absolute;
  width: 34px;
  height: 4px;
  background: var(--handle);
  border-radius: 4px;
  top: 8px;
  left: calc(50% - 17px);
}
.expanded .drawer-handle {
  display: block;
}
.expanded .drawer-header {
  padding-top: 22px;
  min-height: 64px;
}
.drawer-content {
  padding: 0 16px 4px;
}
.drawer-clear {
  display: block;
  margin: 0 auto;
  font-size: 12px;
}
.destination-button {
  width: 100%;
  border: 0;
  background: var(--surface-soft);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  text-align: left;
  margin: 8px 0;
}
.destination-button .icon {
  color: var(--blue);
}
.destination-button small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 3px;
  overflow-wrap: anywhere;
}
.destination-button strong {
  font-size: 12px;
}
.chevron {
  margin-left: auto;
  color: var(--muted);
}
.primary {
  background: var(--button);
  color: var(--on-accent);
  border: 0;
  border-radius: 11px;
  min-height: 46px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 650;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.primary .icon {
  width: 18px;
  height: 18px;
}
.section-label {
  text-transform: uppercase;
  letter-spacing: 1.2px;
  font-size: 10px;
  color: var(--muted);
  margin: 28px 0 12px;
  font-weight: 650;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 17px;
  margin: 12px 0;
}
.row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.provider-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  color: var(--blue);
}
.provider-icon.cloud {
  color: var(--warm);
  background: var(--warm-soft);
}
.row-copy {
  min-width: 0;
  flex: 1;
}
.row-copy p {
  font-size: 12px;
  color: var(--muted);
  margin: 5px 0;
  overflow-wrap: anywhere;
}
.badge {
  font-size: 10px;
  color: var(--success);
  background: var(--success-soft);
  border-radius: 5px;
  padding: 4px 6px;
  white-space: nowrap;
}
.badge.offline {
  color: var(--warm);
  background: var(--warm-soft);
}
.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
  margin-top: 16px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}
.note {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.7;
  padding: 4px 5px;
}
.note strong {
  color: var(--text);
}
.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin: 22px 0 9px;
}
.progress-info strong {
  color: var(--blue);
}
progress {
  appearance: none;
  width: 100%;
  height: 6px;
  border: 0;
  border-radius: 10px;
  background: var(--track);
  display: block;
}
progress::-webkit-progress-bar {
  background: var(--track);
  border-radius: 10px;
}
progress::-webkit-progress-value {
  background: var(--blue);
  border-radius: 10px;
}
progress::-moz-progress-bar {
  background: var(--blue);
  border-radius: 10px;
}
.actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}
.secondary {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  min-height: 44px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  flex: 1;
}
.danger {
  color: var(--danger);
}
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  min-height: 62px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.setting-row:last-child {
  border: 0;
}
.setting-row button {
  max-width: 50%;
  text-align: right;
}
.switch {
  appearance: none;
  width: 44px;
  height: 27px;
  border-radius: 20px;
  background: var(--switch-off);
  flex-shrink: 0;
  position: relative;
  cursor: pointer;
}
.switch:checked {
  background: var(--blue);
}
.switch:before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 4px #0002;
  transition: transform 0.15s;
}
.switch:checked:before {
  transform: translateX(17px);
}
.empty {
  text-align: center;
  padding: 48px 12px;
  color: var(--muted);
  font-size: 14px;
}
.empty .icon {
  width: 32px;
  height: 32px;
  margin-bottom: 10px;
}
dialog {
  border: 0;
  padding: 0;
  width: 100%;
  max-width: 600px;
  max-height: 90dvh;
  margin: auto auto 0;
  border-radius: 24px 24px 0 0;
  color: var(--text);
  background: var(--sheet);
  box-shadow: 0 -10px 80px #16233a20;
}
dialog::backdrop {
  background: var(--backdrop);
  backdrop-filter: blur(3px);
}
#sheet-content {
  padding: 10px 24px calc(24px + env(safe-area-inset-bottom));
}
.handle {
  width: 36px;
  height: 4px;
  border-radius: 4px;
  background: var(--handle);
  margin: 0 auto 13px;
}
.sheet-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.sheet-heading h2 {
  font-size: 23px;
}
.close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-soft);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.pick-row {
  width: 100%;
  text-align: left;
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 15px;
  border-radius: 13px;
  margin: 10px 0;
  min-height: 74px;
}
.pick-row.chosen {
  border-color: var(--chosen-border);
  background: var(--chosen);
}
.pick-row .chosen-icon {
  color: var(--blue);
}
.provider-list .pick-row small {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}
form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin: 15px 0 6px;
}
form input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 13px;
  background: var(--surface);
  color: var(--text);
  min-height: 46px;
  font-size: 16px;
}
form .primary {
  margin-top: 22px;
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--bottom) + 20px);
  transform: translateX(-50%);
  background: var(--toast);
  color: var(--toast-text);
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 12px;
  z-index: 20;
  max-width: 90%;
  width: max-content;
  box-shadow: 0 5px 25px #0002;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}
.toast.visible {
  opacity: 1;
}
.preview {
  width: 100%;
  border-radius: 12px;
  margin-top: 15px;
  max-height: 48dvh;
  object-fit: cover;
}
.preview-meta {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
[hidden] {
  display: none !important;
}
@media (min-width: 650px) {
  body {
    padding: 24px 0;
  }
  .app {
    min-height: calc(100dvh - 48px);
    border-radius: 22px;
    box-shadow: 0 12px 60px #20304712;
    overflow: hidden;
  }
  .tabbar {
    bottom: 24px;
    border-radius: 0 0 22px 22px;
  }
  :root {
    --dock-offset: 24px;
  }
  dialog {
    margin: auto;
    border-radius: 24px;
    max-width: 520px;
  }
  .toast {
    bottom: calc(var(--bottom) + 44px);
  }
}
@media (max-width: 360px) {
  main {
    padding-left: 16px;
    padding-right: 16px;
  }
  .brand {
    padding-left: 16px;
    padding-right: 16px;
  }
  .chip {
    padding: 8px 10px;
  }
  .drawer-header {
    padding-left: 16px;
    padding-right: 16px;
  }
  .demo-label {
    font-size: 8px;
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before {
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

/* Small, fixed swatches preview each palette without changing the current theme. */
.theme-option small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.theme-preview {
  display: flex;
  align-items: end;
  gap: 3px;
  width: 44px;
  height: 44px;
  padding: 8px 6px;
  border-radius: 11px;
  flex-shrink: 0;
  background: #edf1f7;
  border: 1px solid #7d87a344;
}
.theme-preview i {
  width: 8px;
  height: 20px;
  border-radius: 3px;
  background: #2463eb;
}
.theme-preview i:nth-child(2) {
  height: 14px;
  opacity: 0.7;
}
.theme-preview i:nth-child(3) {
  height: 24px;
  opacity: 0.45;
}
.theme-preview-system {
  background: linear-gradient(90deg, #edf1f7 50%, #252a33 50%);
}
.theme-preview-dark {
  background: #252a33;
}
.theme-preview-dark i {
  background: #a3beff;
}
.theme-preview-colorful {
  background: #eee4fc;
}
.theme-preview-colorful i {
  background: #7644c9;
}
.theme-preview-colorful i:nth-child(2) {
  background: #168579;
  opacity: 1;
}
.theme-preview-magic {
  background: #171f36;
}
.theme-preview-magic i {
  background: #baafff;
}
.theme-preview-magic i:nth-child(2) {
  background: #77dce8;
  opacity: 1;
}
.theme-check {
  width: 22px;
  flex-shrink: 0;
  color: var(--blue);
}
.primary,
.tile.selected {
  box-shadow: var(--glow);
}
.tile.selected {
  box-shadow:
    inset 0 0 0 3px var(--blue),
    var(--glow, 0 0 transparent);
}
input::placeholder {
  color: var(--muted);
  opacity: 1;
}
.library-tools option {
  background: var(--surface);
  color: var(--text);
}
