/* Admin-only styles. Lives at the site root (not /admin/) so the login page can load it. */
:root {
  --line-strong: #9AA0B5;
  --danger-bg: #B42318; --danger-hover: #912018;
  --track: #B7BCCD;
  --shadow-lg: 0 20px 60px rgba(20,22,40,.25);
  --scrim: rgba(20,22,40,.45);
}
:root[data-theme="dark"] {
  --line-strong: #5A6078;
  --danger-bg: #D92D20; --danger-hover: #E5483B;
  --track: #4A506A;
  --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
  --scrim: rgba(0,0,0,.6);
}

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row { display: flex; align-items: center; gap: 10px; }

/* buttons */
.btn { border-color: var(--line-strong); background: var(--surface); }
.btn:hover { background: var(--hover); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover { background: var(--hover); }
.btn-danger { background: var(--danger-bg); border-color: var(--danger-bg); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger-quiet { border-color: transparent; background: transparent; color: var(--danger); }
.btn-danger-quiet:hover { background: var(--danger-soft); }
.btn-block { width: 100%; min-height: 48px; font-size: 16px; }
.btn[disabled] { cursor: progress; opacity: .7; }
.btn-primary[disabled] { opacity: .85; }

.pill {
  display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 650; letter-spacing: .02em;
}

/* form fields */
.field {
  display: block; width: 100%; min-height: 44px; padding: 0 14px; border-radius: 12px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px;
}
textarea.field { padding: 10px 14px; min-height: 140px; resize: vertical; line-height: 1.5; }
.field:hover { border-color: var(--muted); }
.field:focus { outline: 3px solid var(--ring); outline-offset: 1px; border-color: var(--ring); }
.field[aria-invalid="true"] { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
.label { font-weight: 600; font-size: 15px; }
.fieldgroup { display: flex; flex-direction: column; gap: 8px; }
.field-foot { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.counter { margin-left: auto; flex: none; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.counter.near { color: var(--danger); font-weight: 650; }
.error-text { margin: 0; display: flex; align-items: center; gap: 6px; color: var(--danger); font-size: 14px; font-weight: 600; }

/* login */
.login-page { min-height: 100vh; display: flex; flex-direction: column; }
.login-top { display: flex; justify-content: flex-end; padding: 12px 16px 0; }
.login-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px 16px 64px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); padding: 32px 28px;
}
.login-brand { display: flex; align-items: center; justify-content: center; gap: 10px; margin-bottom: 24px; font-weight: 650; font-size: 17px; letter-spacing: -.01em; }
.login-brand .logo { width: 36px; height: 36px; border-radius: 11px; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; line-height: 1.25; letter-spacing: -.015em; text-align: center; }
.login-card .lead { margin: 0 0 24px; color: var(--muted); text-align: center; }
.login-form { display: flex; flex-direction: column; gap: 20px; }
.pw-wrap { position: relative; }
.pw-wrap .field { min-height: 48px; padding-right: 52px; }
.pw-wrap .iconbtn { position: absolute; top: 2px; right: 2px; }
.backlink {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 0 10px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-size: 15px;
}
.backlink:hover { color: var(--text); background: var(--hover); }
.spin { animation: nbspin .8s linear infinite; }
@keyframes nbspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }

/* admin layout */
.admin-header .wrap { min-height: 68px; flex-wrap: wrap; padding-top: 8px; padding-bottom: 8px; height: auto; }
.admin-main { padding-top: 32px; padding-bottom: 96px; display: flex; flex-direction: column; gap: 24px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 28px; line-height: 1.2; letter-spacing: -.015em; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.searchbox { position: relative; flex: 1 1 260px; max-width: 420px; }
.searchbox svg { position: absolute; left: 14px; top: 13px; pointer-events: none; }
.search { padding-left: 42px; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.seg button {
  min-height: 38px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); }
.count { font-size: 12px; font-weight: 650; opacity: .85; }

.switch { display: inline-flex; align-items: center; justify-content: center; width: 48px; height: 44px; padding: 0; border: 0; background: transparent; cursor: pointer; border-radius: 12px; }
.switch .track { position: relative; display: block; width: 40px; height: 24px; border-radius: 999px; background: var(--track); transition: background .15s; }
.switch .knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.3); transition: transform .15s; }
.switch[aria-checked="true"] .track { background: var(--accent); }
.switch[aria-checked="true"] .knob { transform: translateX(16px); }
@media (prefers-reduced-motion: reduce) { .switch .track, .switch .knob { transition: none; } }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.tablebox { overflow-x: auto; border-radius: 12px; }
table.notes { width: 100%; min-width: 880px; border-collapse: collapse; }
table.notes th { text-align: left; font-size: 13px; font-weight: 650; color: var(--muted); padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.notes td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 15px; }
table.notes tr:last-child td { border-bottom: 0; }
table.notes th.c, table.notes td.c { text-align: center; padding-left: 4px; padding-right: 4px; }
.fade { display: block; overflow-wrap: anywhere; }
.is-hidden .fade { opacity: .62; }
.note-title { font-weight: 650; }
.hbadge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--hover); color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap;
}
table.notes .hbadge { margin-top: 4px; }
.clamp2 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; overflow: hidden; color: var(--muted); max-width: 420px; }
.date { color: var(--muted); white-space: nowrap; }
.actions { display: flex; gap: 4px; justify-content: flex-end; }

.only-mobile { display: none; }
@media (max-width: 819px) { .only-desktop { display: none; } .only-mobile { display: flex; } }
.mcards { flex-direction: column; gap: 12px; }
.mcard { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.mcard-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.mcard .note-title { font-size: 17px; line-height: 1.35; }
.mcard .clamp2 { max-width: none; }
.mcard-toggles { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 6px; }
.mcard-toggles span { display: inline-flex; align-items: center; font-size: 14px; font-weight: 600; }
.mcard-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.mcard-foot .date { font-size: 13px; }

.statepanel { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 72px 20px; }
.statepanel.small { padding: 48px 20px; gap: 4px; }
.statepanel h2 { margin: 0; font-size: 18px; }
.statepanel.big h2 { margin: 12px 0 0; font-size: 20px; letter-spacing: -.01em; }
.statepanel p { margin: 0; color: var(--muted); max-width: 340px; }
.statepanel .btn { margin-top: 8px; }

/* dialogs */
dialog.dialog {
  width: calc(100% - 32px); max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; margin: auto;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow-lg); padding: 24px;
}
dialog.dialog.narrow { max-width: 400px; }
dialog.dialog::backdrop { background: var(--scrim); }
.dialog-form { display: flex; flex-direction: column; gap: 20px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2, .dialog h2 { margin: 0; font-size: 20px; letter-spacing: -.01em; }
.dialog-head .iconbtn { margin-right: -8px; }
.dialog p.desc { margin: 8px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.dialog-actions.spaced { margin-top: 24px; }
.togglebox { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 12px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 8px 6px 16px; }
.toggle-row + .toggle-row { border-top: 1px solid var(--line); }
.toggle-row .t { display: flex; flex-direction: column; }
.toggle-row .t b { font-weight: 600; font-size: 15px; }
.toggle-row .t small { color: var(--muted); font-size: 14px; }

/* toasts */
.toastbox { position: fixed; left: 0; right: 0; bottom: 24px; z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 18px 0 14px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 15px; box-shadow: var(--shadow-lg);
}
.toast.error { background: var(--danger-bg); color: #fff; }
