/* © 2026 Shaik Ismail. All rights reserved. */
/* WisdomOcean: muted, high-legibility palettes.
   Each theme only sets colour tokens, so a [data-theme] attribute on any element
   (the page root, or a preview swatch in the theme picker) re-colours it. */
:root {
  /* Left pane and top bar text; follows the main text unless a custom theme sets it. */
  --side-text: var(--text);
  --side-muted: var(--muted);
  --quote-size: 32px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
:root[data-font="book"] { --serif: Georgia, "Times New Roman", Times, serif; }
:root[data-font="modern"] { --serif: var(--sans); }

/* Parchment (default light) */
:root, [data-theme="parchment"] {
  --bg: #f3efe7; --panel: #e9e3d7; --surface: #faf8f3; --line: #d6cdbc;
  --text: #35424a; --muted: #646a63; --accent: #5e7a66; --accent-ink: #ffffff;
  --accent-soft: #dde4da; --fav: #9a7632; --danger: #964c42;
  --shadow: 0 1px 2px rgb(40 35 25 / .06), 0 6px 20px rgb(40 35 25 / .06);
  color-scheme: light;
}
/* Automatic: Night when the device is in dark mode */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #1d2220; --panel: #252b28; --surface: #2b322e; --line: #3b4440;
    --text: #dcd6c8; --muted: #a3a89f; --accent: #9db59f; --accent-ink: #16201a;
    --accent-soft: #34413a; --fav: #d6b46d; --danger: #db8d80;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
    color-scheme: dark;
  }
}
[data-theme="sage"] {
  --bg: #eef1ea; --panel: #e1e7dc; --surface: #f8faf5; --line: #c9d3c3;
  --text: #2f3d36; --muted: #5b675f; --accent: #4f7059; --accent-ink: #ffffff;
  --accent-soft: #d6e0d3; --fav: #85692a; --danger: #94483f;
  --shadow: 0 1px 2px rgb(30 45 35 / .06), 0 6px 20px rgb(30 45 35 / .06);
  color-scheme: light;
}
[data-theme="ocean"] {
  --bg: #eaeff2; --panel: #dce4ea; --surface: #f6f9fa; --line: #c3d0d9;
  --text: #2b3c49; --muted: #586975; --accent: #3e6b85; --accent-ink: #ffffff;
  --accent-soft: #d2e0e9; --fav: #86672a; --danger: #984842;
  --shadow: 0 1px 2px rgb(25 40 55 / .07), 0 6px 20px rgb(25 40 55 / .07);
  color-scheme: light;
}
[data-theme="rose"] {
  --bg: #f4ecec; --panel: #eadfdf; --surface: #fbf7f6; --line: #dbc9c9;
  --text: #463a3e; --muted: #6c5f63; --accent: #855662; --accent-ink: #ffffff;
  --accent-soft: #ecdcdd; --fav: #8f6c2b; --danger: #97443c;
  --shadow: 0 1px 2px rgb(60 35 40 / .06), 0 6px 20px rgb(60 35 40 / .06);
  color-scheme: light;
}
[data-theme="night"] {
  --bg: #1d2220; --panel: #252b28; --surface: #2b322e; --line: #3b4440;
  --text: #dcd6c8; --muted: #a3a89f; --accent: #9db59f; --accent-ink: #16201a;
  --accent-soft: #34413a; --fav: #d6b46d; --danger: #db8d80;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
  color-scheme: dark;
}
[data-theme="deepsea"] {
  --bg: #162029; --panel: #1d2933; --surface: #23313c; --line: #344552;
  --text: #d5dde2; --muted: #9aaab4; --accent: #8db4c8; --accent-ink: #10202a;
  --accent-soft: #2b404e; --fav: #d8b46a; --danger: #e0948a;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 6px 20px rgb(0 0 0 / .25);
  color-scheme: dark;
}
/* High contrast: for low vision, deliberately not muted */
[data-theme="contrast"] {
  --bg: #ffffff; --panel: #f0f0f0; --surface: #ffffff; --line: #6e6e6e;
  --text: #111111; --muted: #3a3a3a; --accent: #1d4a73; --accent-ink: #ffffff;
  --accent-soft: #d9e6f2; --fav: #6f4b00; --danger: #a3000d;
  --shadow: none;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.app { display: grid; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; }

/* Top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { margin: 0 8px 0 0; font: 600 22px/1 var(--serif); letter-spacing: .01em; }
.search {
  flex: 1 1 160px; min-width: 0; max-width: 300px; min-height: 44px;
  padding: 8px 14px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}
.group { display: flex; align-items: center; gap: 8px; }
.size-group input[type="range"] { width: 110px; accent-color: var(--accent); }
.size-group output { min-width: 3.2em; font-variant-numeric: tabular-nums; color: var(--muted); }
.big-a { font-size: 21px; }

/* Buttons */
.btn {
  min-height: 44px; padding: 8px 16px; font: inherit; font-weight: 500;
  color: var(--text); background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.icon { min-width: 44px; padding: 8px 10px; }
.btn.full { width: 100%; text-align: left; }
.btn.fav.on { color: var(--fav); border-color: var(--fav); }
.btn.danger, .btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { color: var(--danger); background: transparent; }
.select {
  min-height: 44px; padding: 8px 10px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
}

.switch {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 6px 4px; font: inherit; font-weight: 500; color: inherit;
  background: none; border: 0; cursor: pointer;
}
.switch-track {
  position: relative; width: 48px; height: 28px; border-radius: 14px;
  background: var(--line); transition: background .15s;
}
.switch-thumb {
  position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface); box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s;
}
.switch[aria-checked="true"] .switch-track { background: var(--accent); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(20px); }

/* Body: two panes */
.body { display: grid; grid-template-columns: 260px 1fr; min-height: 0; }
.sidebar {
  display: flex; flex-direction: column; gap: 6px; overflow: auto;
  padding: 14px 12px; background: var(--panel); border-right: 1px solid var(--line);
}
.side-label {
  margin: 14px 10px 4px; font-size: 13px; font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.cat-row { border-radius: 10px; }
.cat-row.active { background: var(--accent-soft); }
.cat-btn {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  width: 100%; min-height: 44px; padding: 8px 10px; font: inherit; color: var(--side-text);
  text-align: left; background: none; border: 0; border-radius: 10px; cursor: pointer;
}
.cat-btn:hover { background: var(--accent-soft); }
.cat-row.active .cat-btn { font-weight: 600; }
.cat-name { overflow-wrap: anywhere; }
.count { color: var(--muted); font-size: 15px; font-variant-numeric: tabular-nums; }
.cat-tools { display: flex; gap: 6px; padding: 0 10px 8px; }
.mini {
  min-height: 34px; padding: 4px 10px; font: inherit; font-size: 15px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; cursor: pointer;
}
.mini.danger { color: var(--danger); }
.sidebar-foot { margin-top: auto; padding-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.hint { margin: 4px 2px 0; font-size: 14px; color: var(--muted); }
.backdrop { display: none; }
.sidebar, .topbar { color: var(--side-text); --muted: var(--side-muted); }
.sidebar .btn.ghost, .topbar .btn.ghost { color: var(--side-text); }

/* Main pane */
.main { overflow: auto; padding: 24px clamp(16px, 4vw, 56px) 48px; outline: none; }
.card { max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; color: var(--muted); font-size: 15px; }
.chip {
  padding: 3px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
  color: var(--side-text); font-weight: 500;
}
.stage {
  display: flex; align-items: center; justify-content: center; min-height: 42vh;
  padding: clamp(20px, 4vw, 48px); background: var(--surface);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.stage figure { margin: 0; width: 100%; }
.quote {
  margin: 0; font-family: var(--serif); font-size: var(--quote-size); line-height: 1.4;
  white-space: pre-wrap; overflow-wrap: break-word; hyphens: auto; -webkit-hyphens: auto; text-wrap: pretty;
}
.author {
  margin-top: .9em; font-size: max(17px, calc(var(--quote-size) * .55));
  color: var(--muted); font-style: italic; font-family: var(--serif);
}
.image { text-align: center; }
.image img { display: block; max-width: 100%; max-height: 64vh; margin: 0 auto; border-radius: 10px; }
.image figcaption { margin-top: 12px; color: var(--muted); font-size: max(17px, calc(var(--quote-size) * .5)); font-family: var(--serif); font-style: italic; }
.nav, .actions { display: flex; flex-wrap: wrap; gap: 10px; }
.nav { justify-content: space-between; }
.notes { display: flex; flex-direction: column; gap: 8px; }
.notes-head { display: flex; align-items: baseline; gap: 12px; }
.notes-head h2 { margin: 0; font-size: 17px; }
.notes-status { color: var(--muted); font-size: 14px; }
.notes-input, .field textarea, .field input:not([type="file"]):not([type="radio"]), .field-input {
  width: 100%; padding: 10px 12px; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px; resize: vertical;
}
.empty { max-width: 520px; margin: 12vh auto 0; text-align: center; color: var(--muted); font-size: 19px; }

/* Dialogs */
dialog {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 22px;
  color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow);
}
dialog::backdrop { background: rgb(20 20 15 / .45); }
dialog h2 { margin: 0 0 14px; font: 600 22px/1.3 var(--serif); }
dialog form { display: flex; flex-direction: column; gap: 14px; }
#ask-message:empty { display: none; }
#ask-message { margin: 0; }
.type-pick { display: flex; gap: 20px; margin: 0; padding: 0; border: 0; }
.type-pick legend { padding: 0; margin-bottom: 6px; font-weight: 500; }
.type-pick label { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.type-pick input { width: 20px; height: 20px; accent-color: var(--accent); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.field textarea, .field input, .field select { font-weight: 400; }
.opt { color: var(--muted); font-weight: 400; }
.preview { max-width: 100%; max-height: 200px; border-radius: 10px; align-self: flex-start; }
.form-error { margin: 0; color: var(--danger); }
.form-error:empty { display: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.menu-btn { display: none; }

/* Phones and narrow windows: categories slide in from the left. */
@media (max-width: 760px) {
  .menu-btn { display: inline-block; }
  .brand { font-size: 20px; margin-right: auto; }
  .search { order: 10; flex-basis: 100%; max-width: none; }
  .topbar { gap: 8px 10px; }
  .size-group { gap: 6px; }
  .size-group input[type="range"] { width: 72px; }
  .size-group output { display: none; }
  #theme-btn { padding: 8px 10px; }
  .body { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; z-index: 20; top: 0; bottom: 0; left: 0; width: min(300px, 85vw);
    transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .backdrop { display: block; position: fixed; inset: 0; z-index: 15; background: rgb(20 20 15 / .4); }
  .main { padding: 16px 16px 40px; }
  .stage { min-height: 34vh; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* Theme picker */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
.theme-card {
  display: flex; flex-direction: column; gap: 8px; padding: 8px; cursor: pointer;
  border: 2px solid var(--line); border-radius: 14px; background: var(--surface);
}
.theme-card:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.theme-card:has(input:focus-visible) { outline: 3px solid var(--accent); outline-offset: 2px; }
.theme-card input { position: absolute; opacity: 0; pointer-events: none; }
.theme-name { font-weight: 600; line-height: 1.2; }
.theme-note { display: block; font-weight: 400; font-size: 14px; color: var(--muted); }
.theme-previews { display: flex; height: 64px; border-radius: 9px; overflow: hidden; border: 1px solid var(--line); }
.theme-preview { flex: 1; display: flex; background: var(--bg); }
.tp-side { width: 26%; background: var(--panel); border-right: 1px solid var(--line); }
.tp-main { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 6px; padding: 6px 8px; }
.tp-quote { font: 600 20px/1 var(--serif); color: var(--text); }
.tp-btn { width: 60%; height: 8px; border-radius: 4px; background: var(--accent); }
#theme-dialog { width: min(680px, calc(100vw - 32px)); }
.font-pick label { font-size: 17px; }
.font-pick [data-font-sample="classic"] { font-family: "Iowan Old Style", "Palatino Linotype", Palatino, serif; }
.font-pick [data-font-sample="book"] { font-family: Georgia, "Times New Roman", serif; }
.font-pick [data-font-sample="modern"] { font-family: var(--sans); }

/* Custom colours */
.colour-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 12px; }
.colour-head h3 { margin: 0; font-size: 18px; }
.colour-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px 16px; }
.colour-row {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 12px;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.colour-row input[type="color"] {
  width: 64px; height: 44px; padding: 3px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
}
.colour-warn { grid-column: 1 / -1; margin: 0; font-size: 14px; color: var(--danger); }
.colour-warn:empty { display: none; }

/* Full screen (focus) mode: only the quote or image */
body.focus .topbar, body.focus .sidebar, body.focus .backdrop { display: none !important; }
body.focus .app { grid-template-rows: 1fr; }
body.focus .body { grid-template-columns: 1fr; }
body.focus .main { padding: 0; }
body.focus .card { max-width: none; min-height: 100%; gap: 0; }
body.focus .card > :not(.stage) { display: none; }
body.focus .stage {
  flex: 1; min-height: 100vh; min-height: 100dvh; border: 0; border-radius: 0; box-shadow: none;
  padding: clamp(24px, 6vw, 96px) clamp(20px, 6vw, 96px) calc(110px + env(safe-area-inset-bottom));
}
body.focus .image img { max-height: calc(100dvh - 220px); }
.focus-bar {
  position: fixed; z-index: 30; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%); display: flex; gap: 8px; padding: 8px; max-width: calc(100vw - 24px);
  color: var(--side-text); background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: var(--shadow); transition: opacity .2s;
}
.focus-bar .btn { min-width: 52px; font-size: 20px; }
.focus-bar #focus-exit { font-size: 17px; }
body.bar-hidden .focus-bar { opacity: 0; pointer-events: none; }
@media (max-width: 760px) {
  .nav { display: grid; grid-template-columns: 1fr auto 1fr; }
  .nav .btn:last-child { justify-self: end; }
  .focus-bar { gap: 6px; padding: 6px; }
  .focus-bar .btn { min-width: 48px; padding: 8px; }
}

/* Google Drive panel and sync status */
.drive-panel { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.drive-panel .side-label { margin: 0 2px 2px; }
.drive-user { margin: 0 2px; font-weight: 600; overflow-wrap: anywhere; }
.drive-status { margin: 0 2px; font-size: 15px; color: var(--muted); }
.drive-status.error, .drive-status.reconnect { font-weight: 600; }
.btn.google {
  display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  background: #ffffff; color: #1f1f1f; border-color: #747775; font-weight: 500;
}
.btn.google svg { width: 20px; height: 20px; flex: none; }
.sync-pill {
  min-height: 36px; padding: 4px 12px; font: inherit; font-size: 15px; color: inherit;
  background: transparent; border: 1px solid var(--line); border-radius: 999px; cursor: pointer;
}
.sync-pill.attention { border-color: var(--danger); font-weight: 600; }
.focus-bar .btn { white-space: nowrap; }
body.focus .toast { bottom: calc(100px + env(safe-area-inset-bottom)); }

/* Ownership footer, About box and the Terms / Privacy pages */
.legal { margin: 8px 2px 0; font-size: 14px; color: var(--muted); line-height: 1.6; }
.legal a, .linklike { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.linklike { padding: 0; font: inherit; background: none; border: 0; cursor: pointer; }
#about-dialog p { margin: 0; }
#about-dialog a { color: var(--accent); }
body.doc-page { height: auto; }
.doc { max-width: 760px; margin: 0 auto; padding: 32px 16px 64px; font-size: 18px; line-height: 1.65; }
.doc h1 { margin: 16px 0 4px; font: 600 34px/1.2 var(--serif); }
.doc h2 { margin: 32px 0 8px; font: 600 22px/1.3 var(--serif); }
.doc a { color: var(--accent); }
.doc ul { padding-left: 22px; }
.doc li { margin: 6px 0; }
.doc code { font-size: .9em; padding: 1px 6px; border-radius: 6px; background: var(--panel); }
.doc .legal { margin-top: 40px; }
