:root {
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  color-scheme: dark;
  --bg: #0a101b;
  --surface: #101a28;
  --surface-2: #142235;
  --selected: #172e4b;
  --border: #29415b;
  --border-strong: #37668d;
  --text: #f4f8ff;
  --muted: #99acc3;
  --subtle: #71869e;
  --blue: #3d8aff;
  --blue-strong: #2875e9;
  --blue-soft: #a6d2ff;
  --gold: #f3c774;
  --nav: #0e1828f2;
  --danger: #ed9bac;
  --danger-surface: #291d2a;
  --warning-surface: #382c21;
  --warning-border: #87684a;
  --warning-text: #f2d0a4;
  --shadow: #0005;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-2: #f9fbff;
  --selected: #e8f2ff;
  --border: #d4e1ee;
  --border-strong: #8fb9e3;
  --text: #17283c;
  --muted: #60748d;
  --subtle: #8295aa;
  --blue: #246fda;
  --blue-strong: #246bd1;
  --blue-soft: #1d5fac;
  --gold: #ba741a;
  --nav: #fffffff2;
  --danger: #b63852;
  --danger-surface: #fff0f2;
  --warning-surface: #fff5e9;
  --warning-border: #e6be8d;
  --warning-text: #8d551a;
  --shadow: #183c6118;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: var(--bg); }
body { min-width: 320px; min-height: 100vh; margin: 0; color: var(--text); background: var(--bg); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.app-shell { max-width: 700px; min-height: 100vh; margin: auto; padding: 0 16px calc(90px + var(--safe-bottom)); }

.topbar { height: 67px; display: flex; align-items: center; gap: 10px; }
.brand-mark { display: grid; place-items: center; flex: none; width: 36px; height: 36px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--selected); color: var(--blue-soft); }
.brand-mark svg { width: 20px; height: 20px; }
.brand-copy { min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.brand-kicker, .section-kicker { font-size: 9px; font-weight: 800; letter-spacing: .12em; color: var(--blue-soft); }
.brand-copy strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 15px; letter-spacing: -.02em; }
.theme-toggle { display: flex; align-items: center; justify-content: center; gap: 6px; min-width: 36px; height: 33px; margin-left: auto; padding: 0 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 700; }
.theme-toggle:hover { border-color: var(--border-strong); color: var(--text); }
.theme-toggle svg { width: 15px; height: 15px; }
.brand-avatar { display: grid; place-items: center; flex: none; width: 32px; height: 32px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--selected); color: var(--blue-soft); font-size: 11px; font-weight: 800; }

.workspace { padding-top: 6px; }
.section-header { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.section-header h2 { margin: 4px 0 0; font-size: 22px; line-height: 1.1; letter-spacing: -.035em; }
.section-actions { display: flex; align-items: center; gap: 7px; flex: none; }
.record-button { display: flex; align-items: center; justify-content: center; gap: 5px; min-height: 34px; padding: 0 10px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--selected); color: var(--blue-soft); font-size: 11px; font-weight: 800; }
.record-button svg { width: 15px; height: 15px; }
.new-button, .save-button { border: 1px solid #5a9bfa; border-radius: 8px; background: var(--blue-strong); color: #fff; box-shadow: 0 4px 12px color-mix(in srgb, var(--blue-strong) 23%, transparent); font-weight: 800; }
.new-button { display: flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 11px; font-size: 11px; }
.new-button svg { width: 15px; height: 15px; }
.new-button:active, .save-button:active { transform: translateY(1px); }
.search-field { display: flex; align-items: center; gap: 9px; height: 43px; padding: 0 12px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--subtle); }
.search-field:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 18%, transparent); }
.search-field svg { width: 17px; height: 17px; flex: none; }
.search-field input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; }
.search-field input::placeholder, .input-wrap input::placeholder, #note-body::placeholder { color: var(--subtle); }
.search-field kbd { color: var(--subtle); font-family: inherit; font-size: 16px; }
.filters, .tag-filters { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.filters::-webkit-scrollbar, .tag-filters::-webkit-scrollbar { display: none; }
.filters { margin-top: 11px; padding-bottom: 2px; }
.filter, .tag-filter { display: flex; align-items: center; gap: 5px; flex: none; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.filter svg { width: 13px; height: 13px; }
.filter.active, .tag-filter.active { border-color: var(--border-strong); background: var(--selected); color: var(--blue-soft); }
.filter span { color: var(--blue-soft); }
.tag-filters { margin-top: 8px; }
.tag-filters:empty { display: none; }
.tag-filter { padding: 5px 8px; font-size: 10px; }
.tag-filter::before { content: "#"; color: var(--blue); }
.notice { margin-top: 13px; padding: 10px 12px; border: 1px solid var(--warning-border); border-radius: 9px; background: var(--warning-surface); color: var(--warning-text); font-size: 11px; line-height: 1.5; }
.notes-list { display: grid; gap: 8px; margin-top: 14px; }
.note-card { display: block; width: 100%; min-height: 93px; padding: 12px 13px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface); color: var(--text); text-align: left; transition: border-color .15s, background .15s; }
.note-card:hover { border-color: var(--border-strong); background: var(--surface-2); }
.note-top { display: flex; align-items: center; gap: 8px; }
.note-kind { display: grid; place-items: center; flex: none; width: 25px; height: 25px; border: 1px solid var(--border); border-radius: 7px; background: var(--selected); color: var(--blue-soft); }
.note-kind svg { width: 14px; height: 14px; }
.note-title { overflow: hidden; font-size: 13px; font-weight: 760; letter-spacing: -.01em; white-space: nowrap; text-overflow: ellipsis; }
.note-star { margin-left: auto; color: var(--gold); }
.note-star svg { width: 15px; height: 15px; fill: var(--gold); }
.note-preview { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; margin: 7px 0 9px; color: var(--muted); font-size: 11px; line-height: 1.45; white-space: pre-line; }
.note-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.note-date { margin-right: auto; color: var(--subtle); font-size: 10px; }
.note-tag, .note-reminder { padding: 3px 6px; border-radius: 5px; background: var(--selected); color: var(--blue-soft); font-size: 10px; }
.note-reminder { display: flex; align-items: center; gap: 3px; }
.note-reminder svg { width: 11px; height: 11px; }
.loading-card { height: 100px; border: 1px solid var(--border); border-radius: 11px; background: linear-gradient(95deg, var(--surface), var(--surface-2), var(--surface)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { to { background-position-x: -200%; } }

.empty-state { margin: 20px auto 0; padding: 30px 18px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface); text-align: center; }
.empty-illustration { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 12px; border: 1px solid var(--border-strong); border-radius: 12px; background: var(--selected); color: var(--blue-soft); }
.empty-illustration svg { width: 27px; height: 27px; }
.empty-state h3 { margin: 0 0 7px; font-size: 15px; }
.empty-state p { max-width: 260px; margin: 0 auto 15px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.empty-state button { padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--selected); color: var(--blue-soft); font-size: 11px; font-weight: 750; }
.empty-state button span { margin-left: 6px; }
.bottom-nav { position: fixed; z-index: 5; right: 0; bottom: 0; left: 0; display: flex; justify-content: space-around; width: 100%; max-width: 700px; height: calc(65px + var(--safe-bottom)); margin: auto; padding: 7px 8px calc(6px + var(--safe-bottom)); border-top: 1px solid var(--border); background: var(--nav); backdrop-filter: blur(16px); }
.nav-item { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: center; gap: 3px; border: 0; background: none; color: var(--subtle); font-size: 10px; font-weight: 700; }
.nav-item svg { width: 18px; height: 18px; }
.nav-item.selected { color: var(--blue); }

.editor-overlay { position: fixed; z-index: 20; inset: 0; display: flex; align-items: flex-end; justify-content: center; }
.editor-overlay[hidden], .empty-state[hidden], .notice[hidden], .delete-button[hidden] { display: none; }
.editor-backdrop { position: absolute; inset: 0; background: #020812b8; backdrop-filter: blur(4px); }
.editor-sheet { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 700px; height: min(94vh, 850px); border: 1px solid var(--border-strong); border-bottom: 0; border-radius: 17px 17px 0 0; background: var(--bg); box-shadow: 0 -15px 70px #0008; animation: sheet-in .2s ease-out; }
@keyframes sheet-in { from { transform: translateY(25px); opacity: .7; } to { transform: translateY(0); opacity: 1; } }
.editor-header { display: flex; align-items: center; gap: 10px; height: 60px; flex: none; padding: 0 15px; border-bottom: 1px solid var(--border); }
.editor-header h2 { flex: 1; margin: 0; font-size: 15px; letter-spacing: -.02em; }
.icon-button { display: grid; place-items: center; padding: 7px; border: 0; background: none; color: var(--muted); }
.save-button { padding: 8px 10px; font-size: 11px; }
.save-button:disabled { opacity: .55; cursor: default; }
.editor-scroll { overflow-y: auto; padding: 20px 18px calc(30px + var(--safe-bottom)); }
.field-label { display: block; margin-bottom: 9px; color: var(--blue-soft); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
#note-body { width: 100%; min-height: 180px; padding: 13px; border: 1px solid var(--border); border-radius: 10px; outline: 0; background: var(--surface); color: var(--text); font-size: 13px; line-height: 1.55; resize: vertical; }
#note-body:focus, .input-wrap:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px color-mix(in srgb, var(--blue) 18%, transparent); }
.editor-hint { display: flex; justify-content: space-between; gap: 12px; margin: 7px 2px 0; color: var(--subtle); font-size: 10px; line-height: 1.45; }
.editor-hint span:first-child { max-width: 250px; }
.editor-hint span:last-child { white-space: nowrap; }
.editor-divider { margin: 18px 0; border-top: 1px solid var(--border); }
.audio-section { margin: 0 0 20px; padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.audio-section[hidden], .audio-load[hidden], #note-audio[hidden] { display: none; }
.audio-status { margin: 0 0 10px; color: var(--muted); font-size: 11px; line-height: 1.4; }
.audio-load { width: 100%; padding: 11px 13px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--selected); color: var(--blue-soft); font-size: 12px; font-weight: 750; }
.audio-load:disabled { opacity: .6; }
#note-audio { display: block; width: 100%; min-height: 40px; }
.photo-section { margin: 0 0 20px; padding: 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.photo-heading { display: flex; align-items: center; justify-content: space-between; }
.photo-heading .field-label { margin-bottom: 11px; }
.photo-heading span:last-child { align-self: flex-start; color: var(--subtle); font-size: 10px; }
.photo-existing[hidden], .photo-preview[hidden], .photo-retry[hidden], .photo-status[hidden], .photo-overlay[hidden] { display: none; }
.photo-status { margin: 0 0 10px; color: var(--muted); font-size: 11px; }
.photo-preview { display: block; overflow: hidden; width: 100%; padding: 0; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--blue-soft); text-align: left; }
.photo-preview img { display: block; width: 100%; max-height: 270px; object-fit: contain; background: var(--surface-2); }
.photo-preview span { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 37px; font-size: 11px; font-weight: 800; }
.photo-preview svg { width: 15px; height: 15px; }
.photo-retry { width: 100%; min-height: 40px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--selected); color: var(--blue-soft); font-size: 11px; font-weight: 800; }
.photo-pager { display: flex; align-items: center; justify-content: space-between; margin: 8px 0; color: var(--muted); font-size: 11px; font-weight: 750; }
.photo-pager button { width: 34px; height: 30px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); color: var(--text); font-size: 21px; line-height: 1; }
.photo-pager button:disabled { opacity: .35; }
.photo-remove { display: block; margin: 0 auto 12px; padding: 5px 10px; border: 0; background: none; color: var(--danger); font-size: 10px; font-weight: 750; }
.photo-remove:disabled { opacity: .55; }
.pending-photo-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
.pending-photo-list:empty { display: none; }
.pending-photo { position: relative; overflow: hidden; min-height: 76px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); }
.pending-photo img { display: block; width: 100%; height: 70px; object-fit: cover; }
.pending-photo img[hidden] { display: none; }
.pending-photo span { display: block; overflow: hidden; padding: 4px 5px; color: var(--muted); font-size: 9px; white-space: nowrap; text-overflow: ellipsis; }
.pending-photo button { position: absolute; top: 3px; right: 3px; width: 23px; height: 23px; padding: 0; border: 0; border-radius: 6px; background: #0a101bcc; color: #fff; font-size: 17px; line-height: 1; }
.photo-add { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 41px; margin-top: 10px; border: 1px dashed var(--border-strong); border-radius: 8px; background: var(--selected); color: var(--blue-soft); font-size: 11px; font-weight: 800; cursor: pointer; }
.photo-add svg { width: 16px; height: 16px; }
.photo-add input { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.photo-add:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.photo-add.disabled { opacity: .5; cursor: default; }
.photo-help { margin: 8px 0 0; }
.photo-overlay { position: fixed; z-index: 25; inset: 0; display: flex; align-items: center; justify-content: center; }
.photo-backdrop { position: absolute; inset: 0; background: #020812e8; }
.photo-dialog { position: relative; display: flex; flex-direction: column; width: 100%; max-width: 700px; height: 100vh; height: 100dvh; background: var(--bg); }
.photo-header { display: flex; flex: none; align-items: center; justify-content: space-between; min-height: 57px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.photo-header strong { font-size: 13px; }
.photo-header span { margin-left: auto; color: var(--muted); font-size: 11px; }
.photo-stage { position: relative; display: grid; flex: 1; min-height: 0; place-items: center; overflow: auto; padding: 12px; }
.photo-stage img { display: block; max-width: 100%; max-height: 100%; object-fit: contain; }
.photo-full-nav { position: absolute; z-index: 1; top: 50%; width: 34px; height: 42px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--nav); color: var(--text); font-size: 27px; line-height: 1; transform: translateY(-50%); }
.photo-full-nav:disabled { display: none; }
#photo-full-prev { left: 12px; }
#photo-full-next { right: 12px; }
.input-wrap { display: flex; align-items: center; gap: 9px; min-height: 43px; padding: 0 11px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); color: var(--blue-soft); }
.input-wrap svg { width: 16px; height: 16px; flex: none; }
.input-wrap input { width: 100%; min-width: 0; padding: 10px 0; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 12px; color-scheme: inherit; }
.field-help { margin: 7px 0 20px; color: var(--subtle); font-size: 10px; }
.toggle-row { display: flex; align-items: center; gap: 11px; padding: 9px 0 23px; cursor: pointer; }
.toggle-icon { display: grid; place-items: center; width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 9px; background: var(--selected); color: var(--gold); }
.toggle-icon svg { width: 17px; height: 17px; }
.toggle-copy { display: flex; flex: 1; flex-direction: column; gap: 2px; }
.toggle-copy strong { font-size: 12px; }
.toggle-copy small { color: var(--muted); font-size: 10px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 37px; height: 22px; border-radius: 20px; background: var(--border-strong); transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle-row input:checked + .switch { background: var(--blue-strong); }
.toggle-row input:checked + .switch::after { transform: translateX(15px); }
.toggle-row input:focus-visible + .switch { outline: 2px solid var(--blue); outline-offset: 3px; }
.delete-button { display: flex; align-items: center; justify-content: center; gap: 7px; width: 100%; margin-top: 12px; padding: 11px; border: 1px solid var(--danger); border-radius: 9px; background: var(--danger-surface); color: var(--danger); font-size: 11px; font-weight: 750; }
.delete-button svg { width: 15px; height: 15px; }
.record-sheet { position: relative; width: 100%; max-width: 700px; max-height: 90vh; overflow-y: auto; border: 1px solid var(--border-strong); border-bottom: 0; border-radius: 17px 17px 0 0; background: var(--bg); box-shadow: 0 -15px 70px #0008; animation: sheet-in .2s ease-out; }
.record-header { display: flex; align-items: center; justify-content: space-between; min-height: 60px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.record-header h2 { margin: 0; font-size: 15px; }
.record-content { padding: 22px 18px calc(22px + var(--safe-bottom)); text-align: center; }
.record-indicator { display: grid; place-items: center; width: 66px; height: 66px; margin: 0 auto 12px; border: 1px solid var(--border-strong); border-radius: 50%; background: var(--selected); color: var(--blue-soft); }
.record-indicator svg { width: 29px; height: 29px; }
.record-indicator.recording { border-color: var(--danger); background: var(--danger-surface); color: var(--danger); animation: record-pulse 1.5s infinite; }
@keyframes record-pulse { 50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--danger) 15%, transparent); } }
.record-timer { color: var(--text); font-size: 34px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.05em; }
.record-status { min-height: 35px; margin: 6px 0 16px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.record-stop, .record-save, .record-cancel { width: 100%; min-height: 43px; border-radius: 9px; font-size: 12px; font-weight: 800; }
.record-stop { border: 1px solid var(--danger); background: var(--danger-surface); color: var(--danger); }
.record-save { margin-top: 16px; border: 1px solid #5a9bfa; background: var(--blue-strong); color: #fff; }
.record-stop:disabled, .record-save:disabled { opacity: .55; }
.record-stop[hidden], .record-details[hidden] { display: none; }
.record-details { margin-top: 8px; text-align: left; }
#record-preview { display: block; width: 100%; margin-bottom: 18px; }
#record-title { width: 100%; min-height: 43px; padding: 0 11px; border: 1px solid var(--border); border-radius: 9px; outline: none; background: var(--surface); color: var(--text); font-size: 12px; }
.record-cancel { margin-top: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); }
.toast { position: fixed; z-index: 30; bottom: calc(76px + var(--safe-bottom)); left: 50%; width: max-content; min-width: 200px; max-width: calc(100vw - 32px); padding: 10px 14px; border: 1px solid var(--border-strong); border-radius: 9px; background: var(--surface-2); color: var(--text); box-shadow: 0 9px 30px var(--shadow); font-size: 11px; line-height: 1.4; text-align: center; opacity: 0; pointer-events: none; transform: translate(-50%, 15px); transition: opacity .18s, transform .18s; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 390px) {
  .app-shell { padding-right: 13px; padding-left: 13px; }
  .brand-kicker { font-size: 8px; }
  .theme-toggle span { display: none; }
  .record-button { width: 34px; padding: 0; }
  .record-button span { display: none; }
  .filter { padding: 6px 8px; font-size: 10px; }
}

@media (min-width: 701px) {
  .app-shell { padding-right: 26px; padding-left: 26px; border-right: 1px solid var(--border); border-left: 1px solid var(--border); }
  .notes-list { grid-template-columns: 1fr 1fr; }
  .bottom-nav { right: auto; left: 50%; width: 700px; transform: translateX(-50%); }
  .editor-sheet { height: min(85vh, 850px); }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
