:root {
  color-scheme: dark;
  font-family: "Yu Gothic UI", system-ui, sans-serif;
  color: #f0f2ed;
  background: #161918;
  --panel: #202523;
  --border: #3c4540;
  --muted: #b3bdb6;
  --accent: #c7edb5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, select, textarea { font: inherit; }
button, .attach, input, select, textarea {
  color: inherit; background: #252c28; border: 1px solid var(--border);
  border-radius: 9px; padding: .65rem .82rem;
}
button, .attach, select { cursor: pointer; }
button:hover, .attach:hover { border-color: #a4c69a; }
button:disabled { opacity: .55; cursor: wait; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
button.primary { background: var(--accent); color: #182619; border-color: var(--accent); font-weight: 700; }
button.danger { color: #ffc4bc; }
a { color: var(--accent); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.55rem, 4vw, 2.25rem); letter-spacing: -.045em; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
.shell { width: min(1160px, calc(100% - 2.5rem)); margin-inline: auto; }
.topbar { background: #1b1f1d; border-bottom: 1px solid var(--border); }
.top-inner, .heading, .section-heading, .dialog-header, .dialog-footer {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
}
.top-inner { min-height: 76px; padding-block: .75rem; flex-wrap: wrap; }
.wordmark { display: flex; align-items: center; gap: .65rem; font-size: 1.35rem; font-weight: 760; }
.wordmark img { border-radius: 9px; }
.actions, .tabs, .chips { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
main { padding-block: clamp(1.4rem, 4vw, 3rem); }
.heading { margin-bottom: 1.1rem; }
#count, .meta, #editor-status, #status, #backup-status { color: var(--muted); }
.toolbar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: .6rem; }
.tabs { margin-block: .95rem 1.1rem; border-bottom: 1px solid var(--border); }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: transparent; color: var(--muted); }
.tabs [aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); align-items: start; gap: 1rem; }
.card { overflow: hidden; background: var(--panel); border: 1px solid var(--border); border-radius: 15px; }
.card:hover { border-color: #8ba184; }
.card-open { width: 100%; padding: 0; border: 0; border-radius: 0; background: transparent; text-align: start; display: block; }
.card-open:focus-visible { outline-offset: -3px; }
.card-open img { display: block; width: 100%; height: 170px; object-fit: cover; background: #111512; }
.card-copy { display: grid; gap: .55rem; padding: 1rem; }
.meta { font-size: .8rem; overflow-wrap: anywhere; }
.excerpt { white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 4; overflow: hidden; }
.card .chips { padding: 0 1rem 1rem; }
.chip { font-size: .8rem; border-radius: 100px; padding: .35rem .62rem; color: var(--accent); }
.empty { padding: 3.4rem 1rem; text-align: center; border: 1px dashed var(--border); border-radius: 14px; color: var(--muted); }
dialog { padding: 0; color: inherit; width: min(680px, calc(100% - 1.5rem)); max-height: 92dvh; border: 1px solid var(--border); border-radius: 16px; background: var(--panel); }
dialog::backdrop { background: #080c0bd0; }
#card-form, .confirm-form { display: grid; gap: .85rem; padding: clamp(.9rem, 4vw, 1.45rem); }
.confirm-form .actions { justify-content: flex-end; }
#confirm, #backup-dialog, #settings-dialog { max-width: 460px; }
.close { font-size: 1.25rem; line-height: 1; padding: .55rem .7rem; }
#card-fields { display: grid; gap: 1rem; min-inline-size: 0; border: 0; padding: 0; margin: 0; }
#original-summary { cursor: pointer; }
#original-details:has(#original-summary:not([hidden])) > label { margin-top: .38rem; }
#suggested-tags { max-height: 12rem; overflow-y: auto; padding: .2rem; }
.stack, label:not(.attach, .check) { display: grid; gap: .38rem; }
.row { display: flex; align-items: end; gap: .55rem; }
.row > input, .row > label { flex: 1; min-width: 0; }
input, textarea { width: 100%; min-width: 0; }
textarea { resize: vertical; }
.section-heading { margin-bottom: .6rem; }
.attach { position: relative; }
.attach input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.attach:focus-within { outline: 2px solid var(--accent); }
.image-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(178px, 100%), 1fr)); gap: .6rem; }
.attachment { min-width: 0; display: grid; align-content: start; gap: .5rem; background: #171b19; border-radius: 10px; padding: .6rem; }
.preview { padding: 0; overflow: hidden; }
.preview img { display: block; width: 100%; height: 110px; object-fit: contain; }
.check { display: flex; align-items: center; gap: .4rem; }
.check input { width: auto; }
.alt-copy { white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-footer { padding-top: .3rem; border-top: 1px solid var(--border); flex-wrap: wrap; }
#viewer { width: fit-content; max-width: 95vw; }
#viewer form { padding: .4rem; text-align: end; }
#full-image { display: block; max-width: 92vw; max-height: 80dvh; object-fit: contain; }
#status:not(:empty) { margin-bottom: .7rem; }
@media (max-width: 640px) {
  .shell { width: calc(100% - 1.5rem); }
  .top-inner .actions button { font-size: .86rem; padding-inline: .53rem; }
  .toolbar { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .toolbar input { grid-column: 1 / -1; }
  .toolbar select { width: 100%; }
}
