:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --ink: #101828;
  --muted: #7b8290;
  --line: #e3e7ed;
  --blue: #0876ee;
  --soft: #f4f6f9;
}

* { box-sizing: border-box; }
html { background: #fff; }
body { margin: 0; min-width: 320px; color: var(--ink); background: #fff; }
button, input, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

#app { min-height: 100dvh; }
.screen { min-height: 100dvh; padding: max(28px, env(safe-area-inset-top)) 20px 28px; }
.screen.with-tabs { padding-bottom: calc(100px + env(safe-area-inset-bottom)); }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 12px; }
.top-title { margin: 0; font-size: 25px; line-height: 1.2; letter-spacing: -.025em; font-weight: 650; }
.text-action { border: 0; padding: 8px 0; background: transparent; color: var(--blue); font-size: 18px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.text-action:disabled { color: #aab1bc; cursor: default; }
.topbar.center-title { display: grid; grid-template-columns: 1fr auto 1fr; }
.topbar.center-title .text-action:last-child { justify-self: end; }
.topbar.center-title .top-title { font-size: 20px; text-align: center; }

.search-wrap { margin-top: 18px; position: relative; }
.search-input { width: 100%; height: 55px; border: 0; border-radius: 13px; background: var(--soft); color: var(--ink); padding: 0 45px 0 16px; font-size: 18px; line-height: 1.3; appearance: none; -webkit-appearance: none; }
.search-input::placeholder { color: #838b99; opacity: 1; }
.clear-search { position: absolute; right: 7px; top: 7px; min-width: 40px; height: 40px; border: 0; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.result-count { margin: 18px 0 2px; color: var(--muted); font-size: 15px; }
.entry-list { margin-top: 20px; }
.entry-row { display: block; width: 100%; border: 0; border-bottom: 1px solid var(--line); padding: 18px 2px 18px 0; background: transparent; text-align: left; cursor: pointer; }
.entry-row:first-child { padding-top: 10px; }
.entry-title { display: block; font-size: 20px; line-height: 1.42; font-weight: 650; color: var(--ink); overflow-wrap: anywhere; }
.entry-preview { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 5px; color: var(--muted); font-size: 17px; line-height: 1.52; overflow-wrap: anywhere; }
mark { color: inherit; background: #d9eaff; border-radius: 2px; }
.empty { padding: 80px 16px 0; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 20px; margin-bottom: 10px; font-weight: 600; }
.empty p { margin: 0; font-size: 16px; line-height: 1.5; }
.empty .text-action { margin-top: 14px; }

.tabbar { position: fixed; z-index: 5; left: 0; right: 0; bottom: 0; min-height: calc(62px + env(safe-area-inset-bottom)); display: flex; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); background: rgba(255,255,255,.96); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.tab { flex: 1; border: 0; background: transparent; color: var(--muted); font-size: 17px; font-weight: 600; cursor: pointer; }
.tab[aria-current="page"] { color: var(--blue); }

.detail { padding-bottom: calc(125px + env(safe-area-inset-bottom)); }
.section-label { color: var(--muted); font-size: 17px; line-height: 1.4; }
.detail-question { margin-top: 57px; padding-bottom: 26px; border-bottom: 1px solid var(--line); }
.detail-question h2 { margin: 10px 0 0; font-size: 25px; line-height: 1.42; font-weight: 650; overflow-wrap: anywhere; white-space: pre-wrap; }
.detail-answer { margin-top: 34px; }
.detail-answer p { margin: 16px 0 0; font-size: 20px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.fixed-action { position: fixed; z-index: 4; left: 0; right: 0; bottom: 0; padding: 12px 20px calc(18px + env(safe-area-inset-bottom)); background: linear-gradient(to bottom, rgba(255,255,255,.9), #fff 15%); }
.primary-button { width: 100%; min-height: 55px; border: 0; border-radius: 10px; background: var(--blue); color: #fff; font-size: 18px; font-weight: 650; cursor: pointer; }
.primary-button:disabled { background: #bec6d0; cursor: default; }

.editor-form { margin-top: 38px; }
.field { margin-bottom: 30px; }
.field label { display: block; margin-bottom: 12px; font-size: 19px; font-weight: 600; }
.required { color: #e43f4d; }
.field textarea { display: block; width: 100%; border: 1px solid #d8dee7; border-radius: 10px; background: #fff; color: var(--ink); padding: 13px 14px; font-size: 18px; line-height: 1.58; resize: none; overflow-y: hidden; }
.field textarea::placeholder { color: #949cac; opacity: 1; }
.field textarea[name="question"] { min-height: 60px; max-height: 126px; }
.field textarea[name="answer"] { min-height: 185px; max-height: 45dvh; }
.helper { margin: -7px 0 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.danger { display: block; margin: 58px auto 0; border: 0; background: transparent; color: #cc3444; font-size: 17px; cursor: pointer; }

.settings-heading { margin: 48px 0 10px; font-size: 23px; line-height: 1.3; }
.settings-explainer { margin: 0 0 22px; font-size: 17px; line-height: 1.6; color: var(--muted); }
.settings-row { display: block; width: 100%; padding: 19px 0; border: 0; border-top: 1px solid var(--line); background: #fff; text-align: left; cursor: pointer; }
.settings-row:last-of-type { border-bottom: 1px solid var(--line); }
.settings-row strong { display: block; color: var(--ink); font-size: 19px; line-height: 1.4; font-weight: 600; }
.settings-row small { display: block; margin-top: 5px; color: var(--muted); font-size: 15px; line-height: 1.4; }
.settings-count { margin-top: 24px; color: var(--muted); font-size: 16px; }

.preview-summary { margin: 34px 0 24px; font-size: 18px; line-height: 1.6; }
.preview-summary strong { color: var(--blue); }
.preview-list { padding: 0; margin: 0; list-style: none; border-top: 1px solid var(--line); }
.preview-list li { padding: 15px 0; border-bottom: 1px solid var(--line); font-size: 17px; line-height: 1.45; }
.preview-list small { display: block; margin-top: 4px; color: var(--muted); font-size: 14px; }
.import-button { margin-top: 26px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: calc(88px + env(safe-area-inset-bottom)); transform: translate(-50%, 12px); max-width: calc(100vw - 40px); padding: 11px 16px; border-radius: 10px; background: #1a2533; color: #fff; font-size: 15px; line-height: 1.4; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; text-align: center; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  #app { max-width: 430px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
  .tabbar, .fixed-action { left: 50%; right: auto; width: min(430px, 100vw); transform: translateX(-50%); }
}
