/* Dolphin Notes — styles */
:root {
  --bg: #f7f6f2;
  --paper: #fffefb;
  --ink: #23262b;
  --ink-2: #5d636c;
  --ink-3: #959aa3;
  --line: #e6e3dc;
  --line-2: #d8d4cb;
  --hover: rgba(30, 40, 55, .06);
  --surface: #ffffff;
  --shadow: 0 10px 30px rgba(20, 25, 35, .12), 0 2px 6px rgba(20, 25, 35, .06);
  --accent: #1f6fb2;
  --accent-ink: #ffffff;
  --accent-soft: rgba(31, 111, 178, .12);
  --danger: #c2413a;
  --tex: rgba(30, 40, 55, .07);
  --radius: 12px;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-note: var(--font-ui);
  --fs: 18px;
  --lh: 30px;
  --fw: 400;
  --measure: none;
  --pt: 28px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #121417;
  --paper: #181b1f;
  --ink: #e4e6ea;
  --ink-2: #a3a9b2;
  --ink-3: #6e747d;
  --line: #262a30;
  --line-2: #343941;
  --hover: rgba(255, 255, 255, .06);
  --surface: #1f2328;
  --shadow: 0 12px 34px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
  --accent: #5aa9e6;
  --accent-ink: #0d1520;
  --accent-soft: rgba(90, 169, 230, .16);
  --danger: #ef6a62;
  --tex: rgba(255, 255, 255, .055);
  color-scheme: dark;
}
:root[data-accent="lagoon"] { --accent: #12877a; --accent-soft: rgba(18,135,122,.12); }
:root[data-accent="coral"] { --accent: #d0563f; --accent-soft: rgba(208,86,63,.12); }
:root[data-accent="plum"] { --accent: #7d4bb5; --accent-soft: rgba(125,75,181,.12); }
:root[data-accent="graphite"] { --accent: #3d434c; --accent-soft: rgba(61,67,76,.12); }
:root[data-theme="dark"][data-accent="lagoon"] { --accent: #3fc4b2; --accent-soft: rgba(63,196,178,.16); }
:root[data-theme="dark"][data-accent="coral"] { --accent: #f08a73; --accent-soft: rgba(240,138,115,.16); }
:root[data-theme="dark"][data-accent="plum"] { --accent: #b48ce6; --accent-soft: rgba(180,140,230,.16); }
:root[data-theme="dark"][data-accent="graphite"] { --accent: #c3c8cf; --accent-soft: rgba(195,200,207,.16); }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
kbd {
  font: 11px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  padding: 3px 5px; border-radius: 5px;
  border: 1px solid var(--line-2); background: var(--bg); color: var(--ink-2);
}
[hidden] { display: none !important; }

/* ===== Layout ===== */
.app { display: flex; height: 100dvh; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; position: relative; }

/* Sidebar */
.sidebar {
  width: 270px; flex: none; display: flex; flex-direction: column;
  background: var(--bg); border-right: 1px solid var(--line);
  transition: margin-left .22s ease, transform .22s ease;
  padding-top: env(safe-area-inset-top);
}
.app.sidebar-closed .sidebar { margin-left: -270px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 8px 16px; }
.sidebar-title { font-weight: 650; letter-spacing: .01em; }
.note-search { margin: 0 10px 8px; display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 9px; background: var(--hover); color: var(--ink-3); }
.note-search svg { width: 16px; height: 16px; }
.note-search input { border: 0; background: none; outline: none; width: 100%; color: var(--ink); }
.note-list { list-style: none; margin: 0; padding: 4px 8px; overflow-y: auto; flex: 1; }
.note-item {
  display: grid; grid-template-columns: 1fr auto; gap: 2px 6px; align-items: center;
  padding: 9px 10px; border-radius: 9px; cursor: pointer; position: relative;
}
.note-item:hover { background: var(--hover); }
.note-item.active { background: var(--accent-soft); }
.note-item .t { font-weight: 560; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item .p { grid-column: 1 / -1; color: var(--ink-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item .acts { display: flex; gap: 2px; opacity: 0; transition: opacity .12s; }
.note-item:hover .acts, .note-item.active .acts, .note-item:focus-within .acts { opacity: 1; }
.note-item .acts button { border: 0; background: none; padding: 3px; border-radius: 6px; color: var(--ink-3); display: grid; }
.note-item .acts button:hover { color: var(--ink); background: var(--hover); }
.note-item .acts svg { width: 15px; height: 15px; }
.note-item.pinned .pin-ind { color: var(--accent); }
.pin-ind { width: 13px; height: 13px; vertical-align: -1px; margin-right: 4px; }
.note-empty { color: var(--ink-3); padding: 14px 10px; font-size: 14px; }
.sidebar-foot { display: flex; justify-content: space-between; padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.scrim { display: none; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 10px 8px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.topbar-left { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 2px; }
.note-title {
  border: 0; background: none; outline: none; font-weight: 650; font-size: 16px;
  min-width: 0; width: 100%; max-width: 340px; padding: 6px 8px; border-radius: 8px;
}
.note-title:hover { background: var(--hover); }
.note-title:focus { background: var(--hover); box-shadow: 0 0 0 2px var(--accent-soft); }
.save-state { color: var(--ink-3); font-size: 12.5px; white-space: nowrap; }
.offline-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; color: var(--ink-2); background: var(--hover); padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.offline-badge svg { width: 14px; height: 14px; }

.icon-btn {
  position: relative; display: grid; place-items: center;
  width: 36px; height: 36px; border: 0; border-radius: 9px; background: none; color: var(--ink-2);
  transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--ink); }
.icon-btn:focus-visible, .btn:focus-visible, .text-btn:focus-visible, .menu button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 16px; height: 16px; }
.icon-btn .dot { position: absolute; top: 7px; right: 7px; width: 7px; height: 7px; border-radius: 50%; background: #2fb36b; box-shadow: 0 0 0 2px var(--bg); }

/* Menus */
.menu-wrap { position: relative; }
.menu {
  position: absolute; top: calc(100% + 6px); left: 50%; transform: translateX(-50%) translateY(-4px);
  min-width: 220px; padding: 6px; border-radius: 12px; z-index: 30;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .12s, transform .12s;
}
.menu.menu-right { left: auto; right: 0; transform: translateY(-4px); }
.menu.open { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.menu.menu-right.open { transform: translateY(0); }
.menu button {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: none; padding: 8px 10px; border-radius: 8px; color: var(--ink);
}
.menu button svg { width: 17px; height: 17px; color: var(--ink-2); }
.menu button kbd { margin-left: auto; }
.menu button:hover { background: var(--hover); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 5px 4px; }
.show-sm { display: none !important; }

/* Timer strip */
.timer-strip {
  position: absolute; top: calc(62px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 5;
  display: flex; align-items: center; gap: 4px; padding: 3px 4px 3px 12px; border-radius: 99px;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
  font: 600 14px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-variant-numeric: tabular-nums;
}
.timer-strip.ending { color: var(--danger); animation: pulse 1s ease-in-out infinite; }
.timer-strip.done { color: var(--accent); }
@keyframes pulse { 50% { opacity: .55; } }

/* Editor */
.paper { flex: 1; min-height: 0; position: relative; background: var(--paper); display: flex; }
.editor {
  flex: 1; width: 100%; height: 100%; resize: none; border: 0; outline: none;
  background: transparent; color: var(--ink);
  font-family: var(--font-note); font-size: var(--fs); line-height: var(--lh); font-weight: var(--fw);
  padding: var(--pt) max(24px, calc((100% - var(--measure)) / 2)) 120px;
  background-attachment: local;
  tab-size: 4; caret-color: var(--accent);
  scroll-padding-bottom: 120px;
}
.editor::placeholder { color: var(--ink-3); }
.editor::selection { background: var(--accent-soft); }

/* Textures (applied to .paper) */
.paper[data-tex="lined"] .editor { background-image: linear-gradient(to bottom, transparent calc(var(--lh) - 1px), var(--tex) calc(var(--lh) - 1px)); background-size: 100% var(--lh); background-position: 0 var(--pt); background-attachment: local; }
.paper[data-tex="dots"] .editor { background-image: radial-gradient(var(--tex) 1.3px, transparent 1.4px); background-size: 22px 22px; }
.paper[data-tex="grid"] .editor { background-image: linear-gradient(var(--tex) 1px, transparent 1px), linear-gradient(90deg, var(--tex) 1px, transparent 1px); background-size: 22px 22px; }
.paper[data-tex="grain"] .editor { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .5 0 0 0 0 .5 0 0 0 0 .5 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E"); }
.paper[data-tex="linen"] .editor { background-image: repeating-linear-gradient(0deg, var(--tex) 0 1px, transparent 1px 4px), repeating-linear-gradient(90deg, var(--tex) 0 1px, transparent 1px 5px); }
.paper[data-tex="stars"] .editor { background-image: radial-gradient(1px 1px at 20px 30px, var(--ink-3), transparent), radial-gradient(1px 1px at 120px 80px, var(--ink-3), transparent), radial-gradient(1.5px 1.5px at 200px 150px, var(--ink-3), transparent), radial-gradient(1px 1px at 60px 190px, var(--ink-3), transparent), radial-gradient(1px 1px at 260px 40px, var(--ink-3), transparent), radial-gradient(1.2px 1.2px at 170px 230px, var(--ink-3), transparent); background-size: 300px 260px; }

/* Count pill */
.count-pill {
  position: absolute; right: 18px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 4;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  padding: 6px 12px; border-radius: 99px; font-size: 12.5px; box-shadow: 0 2px 8px rgba(0,0,0,.06);
  font-variant-numeric: tabular-nums;
}
.count-pill:hover { color: var(--ink); }
.count-pill.frosted { background: color-mix(in srgb, var(--surface) 55%, transparent); backdrop-filter: blur(12px) saturate(1.4); -webkit-backdrop-filter: blur(12px) saturate(1.4); }

/* Focus mode */
.exit-focus { display: none; }
body.focus .topbar, body.focus .count-pill { opacity: 0; pointer-events: none; }
body.focus .topbar { position: absolute; inset: 0 0 auto 0; z-index: 6; transition: opacity .25s; }
body.focus .app .sidebar { margin-left: -270px; }
body.focus .exit-focus {
  display: grid; place-items: center; position: fixed; top: calc(12px + env(safe-area-inset-top)); right: 14px; z-index: 7;
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  opacity: .25; transition: opacity .2s;
}
body.focus .exit-focus:hover { opacity: 1; }
body.focus { --pt: 56px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 10px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 100; max-width: calc(100% - 32px);
  display: flex; align-items: center; gap: 12px;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast button { border: 0; background: none; color: var(--accent); font-weight: 650; padding: 0; }
:root[data-theme="dark"] .toast button { color: #1f6fb2; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 8px; border: 0; border-radius: 9px; padding: 8px 16px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn svg { width: 16px; height: 16px; }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--hover); color: var(--ink); }
.btn.danger { background: var(--danger); color: #fff; }
.text-btn { border: 0; background: none; color: var(--accent); padding: 6px 8px; border-radius: 8px; font-weight: 560; display: inline-flex; align-items: center; gap: 6px; }
.text-btn svg { width: 16px; height: 16px; }
.text-btn:hover { background: var(--hover); }
.text-btn.danger { color: var(--danger); }
.input { width: 100%; padding: 9px 12px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--paper); outline: none; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.num { width: 90px; }

/* Modals */
.modal {
  width: min(520px, calc(100vw - 24px)); max-height: min(720px, calc(100dvh - 32px));
  padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow); overflow: hidden;
}
.modal[open] { display: flex; flex-direction: column; animation: pop .16s ease; }
.modal.small { width: min(380px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(10, 14, 20, .35); backdrop-filter: blur(2px); }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.modal header { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 6px 20px; }
.modal h2 { margin: 0; font-size: 17px; }
.modal-body { padding: 8px 20px 16px; overflow-y: auto; }
.modal footer { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.modal footer .muted { margin-right: auto; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }

.prefs section { padding: 10px 0; border-bottom: 1px solid var(--line); }
.prefs section:last-child { border-bottom: 0; }
.prefs h3 { margin: 4px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-3); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 7px 0; }
.row > span small { display: block; color: var(--ink-3); font-size: 12.5px; }
.row select { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--paper); min-width: 150px; }
.seg { display: inline-flex; background: var(--hover); padding: 3px; border-radius: 9px; gap: 2px; }
.seg button { border: 0; background: none; padding: 5px 11px; border-radius: 7px; color: var(--ink-2); font-size: 14px; }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }

.switch { appearance: none; -webkit-appearance: none; width: 40px; height: 24px; border-radius: 99px; background: var(--line-2); position: relative; cursor: pointer; flex: none; transition: background .15s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(16px); }
.switch:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 6px 0; }
.stats div { background: var(--hover); border-radius: 10px; padding: 10px 12px; }
.stats dt { font-size: 12.5px; color: var(--ink-2); }
.stats dd { margin: 2px 0 0; font-size: 20px; font-weight: 650; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Snapshots */
.snap-list { list-style: none; padding: 0; margin: 14px 0 0; }
.snap-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.snap-list .meta { flex: 1; min-width: 0; }
.snap-list .when { font-weight: 560; }
.snap-list .prev { color: var(--ink-3); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Keys table */
.keys { width: 100%; border-collapse: collapse; }
.keys td { padding: 8px 0; border-bottom: 1px solid var(--line); }
.keys td:first-child { white-space: nowrap; padding-right: 16px; color: var(--ink-2); }

/* Symbols */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chips button { border: 1px solid var(--line-2); background: none; padding: 5px 11px; border-radius: 99px; font-size: 13.5px; color: var(--ink-2); }
.chips button.on, .chips button:hover { background: var(--accent-soft); border-color: transparent; color: var(--ink); }
.sym-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 4px; max-height: 300px; overflow-y: auto; outline: none; padding: 2px; }
.sym-grid button { aspect-ratio: 1; border: 0; background: var(--hover); border-radius: 8px; font-size: 20px; display: grid; place-items: center; }
.sym-grid button.sel, .sym-grid button:hover { background: var(--accent); color: var(--accent-ink); }

/* Sounds */
.sounds { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-top: 10px; }
.sound { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.sound.on { border-color: var(--accent); background: var(--accent-soft); }
.sound button { border: 0; background: none; padding: 0; text-align: left; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.sound .emo { font-size: 18px; }
.sound input[type=range] { width: 100%; accent-color: var(--accent); }

.about { text-align: left; }
.about img { display: block; margin: 4px 0 8px; border-radius: 14px; }
.about ul { padding-left: 18px; }
.about li { margin: 5px 0; }
.about a { color: var(--accent); }

/* Break reminder */
.break-dim { position: fixed; inset: 0; background: rgba(5, 8, 12, .55); z-index: 90; transition: opacity .6s; }
.break-card {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 91; width: min(420px, calc(100vw - 24px));
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; box-shadow: var(--shadow);
}
.break-card h3 { margin: 0 0 4px; }
.break-card p { margin: 0 0 12px; color: var(--ink-2); }
.break-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Typing sparkle */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.spark { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); animation: spark .55s ease-out forwards; }
@keyframes spark { to { transform: translate(var(--dx), var(--dy)) scale(.2); opacity: 0; } }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 40; margin-left: 0 !important; transform: translateX(-100%); visibility: hidden; background: var(--surface); transition: transform .22s ease, visibility 0s .22s; }
  .app.sidebar-open .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow); transition: transform .22s ease; }
  .app.sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(10,14,20,.3); }
}
@media (max-width: 600px) {
  .hide-sm { display: none !important; }
  .show-sm { display: flex !important; }
  .save-state { display: none; }
  :root { --pt: 20px; }
  .editor { padding: var(--pt) 18px 110px; }
  .topbar { padding-left: 6px; padding-right: 6px; }
  .icon-btn { width: 34px; height: 34px; }
  .note-title { font-size: 15px; }
  .menu kbd { display: none; }
  .sounds, .stats { grid-template-columns: 1fr 1fr; }
  .count-pill { right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* Print = PDF export */
@media print {
  body { overflow: visible; background: #fff; }
  .sidebar, .topbar, .count-pill, .toast, .timer-strip, .exit-focus, dialog, .break-card, .break-dim, .scrim { display: none !important; }
  .app, .main, .paper { display: block; height: auto; background: #fff; }
  .editor { display: none; }
  #printOut { display: block !important; }
}
#printOut { display: none; white-space: pre-wrap; word-wrap: break-word; font: 12pt/1.55 Georgia, "Times New Roman", serif; color: #000; }
#printOut h1 { font: 700 18pt/1.2 var(--font-ui); margin: 0 0 14pt; }
