:root {
  color-scheme: dark;
  --bg: #171c48;
  --glow-a: rgba(116, 91, 255, 0.18);
  --glow-b: rgba(41, 211, 255, 0.1);
  --surface: #0b172b;
  --surface-2: #12203a;
  --surface-3: #1a2b4a;
  --surface-alpha: rgba(11, 23, 43, 0.92);
  --input: #081426;
  --line: rgba(111, 153, 205, 0.3);
  --text: #f8fbff;
  --muted: #a9b9d4;
  --accent: #ff627e;
  --accent-ink: #260712;
  --accent-soft: rgba(255, 98, 126, 0.12);
  --accent-border: rgba(255, 98, 126, 0.48);
  --source-text: #ffc48f;
  --source-soft: rgba(255, 154, 61, 0.13);
  --source-border: rgba(255, 154, 61, 0.45);
  --violet: #7a63ff;
  --green: #43dda2;
  --red: #ff7186;
  --shadow: 0 18px 50px rgba(3, 8, 24, 0.3);
  --brand-logo: url("/assets/unibook-logo-dark.jpg");
}

html[data-theme="light"] {
  color-scheme: light;
  --bg: #eef2ff;
  --glow-a: rgba(112, 87, 255, 0.13);
  --glow-b: rgba(28, 179, 222, 0.1);
  --surface: #ffffff;
  --surface-2: #f4f7ff;
  --surface-3: #e7edfb;
  --surface-alpha: rgba(255, 255, 255, 0.95);
  --input: #f8faff;
  --line: rgba(49, 77, 127, 0.2);
  --text: #13213c;
  --muted: #64728d;
  --accent: #ed4869;
  --accent-ink: #ffffff;
  --accent-soft: rgba(237, 72, 105, 0.1);
  --accent-border: rgba(237, 72, 105, 0.45);
  --source-text: #9a5416;
  --source-soft: #fff2e3;
  --source-border: #ffd0a0;
  --violet: #654ee8;
  --green: #12875d;
  --red: #d83b58;
  --shadow: 0 18px 45px rgba(44, 62, 112, 0.13);
  --brand-logo: url("/assets/unibook-logo-light.jpg");
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 100% 0, var(--glow-a), transparent 30rem),
    radial-gradient(circle at 0 45%, var(--glow-b), transparent 34rem),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, a { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
[hidden] { display: none !important; }

.shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(42px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 22px;
}
.brand {
  margin: 0;
  width: clamp(170px, 28vw, 245px);
  aspect-ratio: 5.2 / 1;
  overflow: hidden;
  background: var(--brand-logo) center / 112% auto no-repeat;
  color: transparent;
  font-size: 1px;
  line-height: 1;
  text-indent: -9999px;
  text-decoration: none;
}
html[data-theme="light"] .brand { mix-blend-mode: multiply; }
html[data-theme="dark"] .brand { mix-blend-mode: lighten; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.pill-button, .icon-button, .primary-button, .danger-button, .secondary-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 800;
}
.pill-button, .icon-button, .secondary-button {
  background: var(--surface-alpha);
  color: var(--text);
}
.pill-button { padding: 8px 13px; text-decoration: none; }
.icon-button { width: 42px; padding: 0; }
.primary-button {
  padding: 10px 18px;
  border-color: transparent;
  background: var(--accent);
  color: var(--accent-ink);
}
.secondary-button { padding: 9px 14px; }
.danger-button {
  padding: 9px 14px;
  border-color: color-mix(in srgb, var(--red) 55%, var(--line));
  background: color-mix(in srgb, var(--red) 10%, transparent);
  color: var(--red);
}
button:disabled { cursor: not-allowed; opacity: 0.45; }

.hero, .panel {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface-alpha);
  box-shadow: var(--shadow);
}
.hero {
  position: relative;
  overflow: hidden;
  padding: clamp(24px, 6vw, 48px);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--violet) 18%, transparent), transparent 55%),
    var(--surface-alpha);
}
.hero::after {
  position: absolute;
  right: -12px;
  bottom: -48px;
  color: color-mix(in srgb, var(--violet) 12%, transparent);
  content: "U";
  font: 700 13rem/1 Georgia, serif;
  pointer-events: none;
}
.eyebrow {
  position: relative;
  z-index: 1;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
.hero h1, .hero h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 760px;
  font-size: clamp(1.8rem, 7vw, 3.5rem);
  line-height: 1.08;
}
.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.75;
}
.stats { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.stat { padding: 8px 12px; border: 1px solid var(--line); border-radius: 999px; background: var(--input); color: var(--muted); }
.stat strong { color: var(--text); }

.panel { margin-top: 18px; padding: 20px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.panel-head h2, .panel-head h3 { margin: 0; }
.panel-head p { margin: 7px 0 0; color: var(--muted); line-height: 1.6; }
.section-title { margin: 30px 2px 12px; }
.section-title h2 { margin: 0; }
.section-title p { margin: 5px 0 0; color: var(--muted); }

.account-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-2);
}
.account-box img { width: 46px; height: 46px; border-radius: 50%; object-fit: cover; }
.account-box div { min-width: 0; flex: 1; }
.account-box strong, .account-box span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-box span { margin-top: 3px; color: var(--muted); font-size: 0.82rem; }
.google-button { display: flex; justify-content: center; min-height: 44px; margin-top: 16px; }
.status { margin: 12px 0 0; color: var(--muted); font-size: 0.86rem; }
.status[data-state="ready"] { color: var(--green); }
.status[data-state="error"] { color: var(--red); }

.mode-grid { display: grid; gap: 10px; margin-top: 18px; }
.mode-option { position: relative; }
.mode-option input { position: absolute; opacity: 0; pointer-events: none; }
.mode-option label {
  display: block;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 17px;
  background: var(--surface-2);
  cursor: pointer;
}
.mode-option label strong, .mode-option label span { display: block; }
.mode-option label span { margin-top: 5px; color: var(--muted); font-size: 0.82rem; line-height: 1.5; }
.mode-option input:checked + label { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 18%, transparent); }
.field { display: grid; gap: 7px; margin-top: 14px; }
.field label { color: var(--muted); font-size: 0.82rem; font-weight: 800; }
.field select {
  width: 100%;
  min-height: 48px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: var(--input);
  color: var(--text);
}
.create-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.create-row p { margin: 0; color: var(--muted); font-size: 0.8rem; }

.share-list { display: grid; gap: 11px; }
.share-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface-alpha);
}
.share-item h3 { margin: 0; font-size: 1rem; }
.share-item p { margin: 6px 0 0; color: var(--muted); font-size: 0.8rem; overflow-wrap: anywhere; }
.share-actions { display: flex; align-items: center; gap: 7px; }
.empty { padding: 32px 18px; border: 1px dashed var(--line); border-radius: 18px; color: var(--muted); text-align: center; }

.toolbar {
  position: sticky;
  z-index: 5;
  top: max(8px, env(safe-area-inset-top));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 16px 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow);
}
.toolbar p { margin: 0; color: var(--muted); font-size: 0.84rem; }
.toolbar-actions { display: flex; gap: 8px; }

.bookmark-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; gap: 12px; }
.bookmark-grid[data-layout="single"] { width: min(100%, 440px); margin-inline: auto; grid-template-columns: minmax(0, 1fr); }
.bookmark-card { position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--surface-alpha); box-shadow: var(--shadow); }
.bookmark-card[data-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 22%, transparent), var(--shadow); }
.card-cover { position: relative; aspect-ratio: 3 / 4; overflow: hidden; background: linear-gradient(145deg, var(--surface-3), var(--surface)); cursor: pointer; }
.card-cover:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.card-cover::after { position: absolute; inset: 45% 0 0; content: ""; background: linear-gradient(transparent, rgba(3, 8, 29, 0.9)); pointer-events: none; }
.card-cover img,
.card-cover video,
.card-cover iframe { width: 100%; height: 100%; display: block; object-fit: cover; }
.card-cover.has-image-gallery { cursor: default; background: #071225; }
.card-cover.has-image-gallery::after { display: none; }
.image-gallery { display: flex; width: 100%; height: 100%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-inline: contain; scrollbar-width: none; touch-action: pan-x pan-y; }
.image-gallery::-webkit-scrollbar { display: none; }
.image-gallery-slide { display: grid; flex: 0 0 100%; width: 100%; height: 100%; place-items: center; scroll-snap-align: center; scroll-snap-stop: always; }
.card-cover .image-gallery-slide img { width: 100%; height: 100%; object-fit: contain; }
.image-count { position: absolute; z-index: 5; top: 10px; right: 10px; min-width: 54px; padding: 6px 9px; border: 1px solid rgba(255,255,255,.42); border-radius: 999px; background: rgba(3,8,29,.74); color: #fff; font-size: .64rem; font-weight: 900; line-height: 1; text-align: center; pointer-events: none; backdrop-filter: blur(8px); }
.threads-gallery-button { position: absolute; z-index: 6; right: 12px; bottom: 12px; min-height: 40px; padding: 8px 13px; border: 1px solid rgba(255,255,255,.48); border-radius: 999px; background: rgba(3,8,29,.82); color: #fff; cursor: pointer; font: inherit; font-size: .75rem; font-weight: 900; box-shadow: 0 8px 22px rgba(3,8,29,.32); backdrop-filter: blur(10px); }
.threads-gallery-dialog { width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0; overflow: hidden; border: 0; background: #020713; color: #fff; }
.threads-gallery-dialog::backdrop { background: #020713; }
.threads-gallery-shell { position: relative; width: 100%; height: 100%; overflow: hidden; }
.threads-gallery-toolbar { position: absolute; z-index: 3; top: 0; right: 0; left: 0; display: flex; align-items: center; justify-content: space-between; padding: max(12px, env(safe-area-inset-top)) 14px 12px; pointer-events: none; }
.threads-gallery-toolbar > * { pointer-events: auto; }
.threads-gallery-close, .threads-gallery-position { min-width: 44px; min-height: 44px; display: grid; place-items: center; border: 1px solid rgba(255,255,255,.36); border-radius: 999px; background: rgba(3,8,29,.76); color: #fff; font: inherit; font-weight: 900; backdrop-filter: blur(10px); }
.threads-gallery-close { cursor: pointer; font-size: 1.35rem; }
.threads-gallery-position { padding-inline: 13px; font-size: .78rem; }
.threads-gallery-track { display: flex; width: 100%; height: 100%; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; overscroll-behavior-inline: contain; scrollbar-width: none; touch-action: pan-x pan-y; }
.threads-gallery-track::-webkit-scrollbar { display: none; }
.threads-gallery-slide { display: grid; flex: 0 0 100%; width: 100%; height: 100%; padding: max(68px, calc(env(safe-area-inset-top) + 56px)) 0 max(18px, env(safe-area-inset-bottom)); place-items: center; scroll-snap-align: center; scroll-snap-stop: always; }
.threads-gallery-slide img { width: 100%; height: 100%; object-fit: contain; }
.card-cover iframe { border: 0; background: #fff; }
.card-cover.is-fallback { aspect-ratio: 4 / 5; }
.card-cover.is-fallback[data-layout="landscape"] { aspect-ratio: 16 / 9; }
.card-cover .fallback-cover { width: 100%; height: 100%; object-fit: cover; object-position: center; }
.card-cover.has-inline-video { cursor: default; }
.card-cover.has-inline-video .card-copy { bottom: 42px; pointer-events: none; }
.card-cover.has-official-embed::after,
.card-cover.has-official-embed .card-copy { display: none; }
.card-cover.has-x-embed {
  display: block;
  min-height: 180px;
  height: auto;
  padding: 8px;
  overflow: visible;
  background: #fff;
  cursor: default;
}
.card-cover.has-x-embed::after,
.card-cover.has-x-embed .card-copy { display: none; }
.x-embed-host { display: grid; width: 100%; min-height: 180px; place-items: center; }
.x-embed-host .twitter-tweet { width: 100% !important; margin: 0 auto !important; }
.official-play-button {
  position: absolute;
  z-index: 3;
  top: 50%;
  left: 50%;
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  padding: 0;
  border: 1px solid rgba(255,255,255,.55);
  border-radius: 50%;
  background: rgba(5,13,27,.76);
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
}
.card-placeholder { display: grid; place-items: center; width: 100%; height: 100%; color: var(--muted); font: 700 4rem/1 Georgia, serif; }
.card-check { position: absolute; z-index: 3; top: 8px; right: 8px; display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid rgba(255,255,255,.45); border-radius: 50%; background: rgba(5,13,27,.78); color: #fff; cursor: pointer; }
.card-check input { position: absolute; opacity: 0; }
.card-check span::before { content: "○"; font-size: 1.1rem; }
.card-check input:checked + span::before { content: "●"; color: var(--accent); }
.card-copy { position: absolute; z-index: 2; right: 9px; bottom: 8px; left: 9px; color: #fff; }
.card-copy h3 { display: -webkit-box; margin: 0; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-size: 0.78rem; line-height: 1.4; }
.card-copy p { margin: 4px 0 0; color: rgba(255,255,255,.72); font-size: 0.68rem; }
.card-body { padding: 9px; border-top: 1px solid var(--line); }
.card-date { margin: 0 0 5px; color: var(--accent); font-size: 0.64rem; font-weight: 900; letter-spacing: 0.04em; }
.card-note { display: -webkit-box; margin: 0 0 7px; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; color: var(--text); font-size: 0.72rem; line-height: 1.45; }
.card-meta { margin: 0; color: var(--muted); font-size: 0.66rem; line-height: 1.45; }
.card-related-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.card-related-links a { padding: 6px 9px; border: 1px solid var(--accent-border); border-radius: 999px; background: var(--accent-soft); color: var(--accent); text-decoration: none; font-size: 0.68rem; font-weight: 900; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.card-actions a,
.card-actions button { padding: 6px 9px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; font: inherit; font-size: 0.68rem; font-weight: 800; cursor: pointer; }
.card-actions a.primary { border-color: var(--source-border); background: var(--source-soft); color: var(--source-text); }

.dialog {
  width: min(calc(100% - 32px), 400px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(4, 8, 24, 0.72); backdrop-filter: blur(6px); }
.dialog-card { padding: 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2 { margin: 0; font-size: 1.25rem; }
.dialog-copy { color: var(--muted); line-height: 1.6; }
.dialog-account { margin-top: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.toast {
  position: fixed;
  z-index: 20;
  right: 16px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 16px;
  width: min(520px, calc(100% - 32px));
  margin: auto;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  text-align: center;
}
.footer { margin-top: 34px; padding: 20px 2px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; }
.footer a { color: inherit; text-underline-offset: 3px; }

@media (min-width: 700px) {
  .mode-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bookmark-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .bookmark-grid[data-layout="single"] { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 940px) {
  .bookmark-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .bookmark-grid[data-layout="single"] { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .shell { padding-inline: 12px; }
  .brand { width: clamp(170px, 42vw, 195px); }
  .top-actions .pill-label { display: none; }
  .share-item { grid-template-columns: 1fr; }
  .share-actions { justify-content: flex-start; }
  .create-row, .toolbar { align-items: stretch; flex-direction: column; }
  .toolbar-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
