:root {
  --bg: #f4f2ee;
  --card: #ffffff;
  --ink: #1d1f1e;
  --muted: #6d716e;
  --line: #e3e0da;
  --accent: #2f5d50;
  --accent-ink: #ffffff;
  --accent-soft: #e3ece8;
  --danger: #b3412f;
  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141615;
    --card: #1d201f;
    --ink: #ecefed;
    --muted: #9aa19d;
    --line: #2c302e;
    --accent: #7fbfa9;
    --accent-ink: #0f1a16;
    --accent-soft: #23302b;
    --danger: #e0806f;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
body.center { display: grid; place-items: center; padding: 24px 16px; }
.mono { font-family: var(--mono); }
a { color: var(--accent); }

/* brand */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; font-size: 20px; letter-spacing: -.01em; color: var(--ink); text-decoration: none; }
.brand.small { font-size: 15px; }
.mark { width: 22px; height: 22px; border-radius: 7px; background: var(--accent); position: relative; flex: none; }
.mark::after { content: ""; position: absolute; left: 7px; top: 4px; width: 6px; height: 11px; border: solid var(--accent-ink); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg); }

/* inputs & buttons */
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; width: 100%;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }
.btn {
  font: inherit; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 10px; padding: 11px 18px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.ghost { background: transparent; padding: 8px 12px; font-weight: 500; font-size: 14px; }
.btn:active, .chip:active { transform: translateY(1px); }
.chip {
  font: inherit; font-size: 13px; font-weight: 550; border: 1px solid var(--line); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 6px 12px; cursor: pointer;
}
.chip.strong { background: var(--accent-soft); border-color: transparent; color: var(--accent); }
.chip.danger { color: var(--danger); }

/* gate */
.gate { width: 100%; max-width: 380px; display: grid; gap: 20px; }
.gate .brand { justify-self: center; margin-bottom: 8px; }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 4px; }
.tabs button { font: inherit; font-size: 14px; font-weight: 550; border: 0; background: transparent; color: var(--muted); padding: 9px; border-radius: 9px; cursor: pointer; }
.tabs button.on { background: var(--accent-soft); color: var(--accent); }
.panel { display: grid; gap: 12px; }
.hint { color: var(--muted); font-size: 14px; margin: 0; }
.code-input {
  font-family: var(--mono); font-size: 30px; letter-spacing: .14em; text-align: center; text-transform: uppercase;
  padding: 16px 10px;
}
.code-input::placeholder { color: var(--line); }
.error { color: var(--danger); margin: 0; text-align: center; font-size: 15px; }
.mine { display: grid; gap: 6px; border-top: 1px solid var(--line); padding-top: 16px; }
.mine-link { display: flex; justify-content: space-between; text-decoration: none; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; }
.mine-link span { color: var(--muted); }

/* board */
.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; max-width: 760px; margin: 0 auto; }
.top form { margin: 0; }
.board { max-width: 760px; margin: 0 auto; padding: 8px 16px 64px; }
.board h1 { font-size: 30px; line-height: 1.2; letter-spacing: -.02em; margin: 12px 0 8px; }
.board h2 { font-size: 18px; margin: 32px 0 12px; }
.lead { color: var(--muted); margin: 0 0 20px; white-space: pre-wrap; }
.empty { color: var(--muted); }
.fields { list-style: none; padding: 0; margin: 20px 0 0; display: grid; gap: 12px; }
.field { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); min-width: 0; }
.k { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 4px; }
.v { font-size: 17px; overflow-wrap: anywhere; white-space: pre-wrap; }
.v.link { text-decoration: none; }
pre.v { margin: 0; font-size: 13.5px; line-height: 1.55; background: var(--bg); border-radius: 8px; padding: 10px 12px; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-all; }
.secret { filter: blur(6px); user-select: none; transition: filter .15s; }
.secret.shown { filter: none; user-select: text; }
.field .actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.field.note { background: var(--accent-soft); border-color: transparent; box-shadow: none; }
.field.note .v { font-size: 15.5px; }

/* QR dialog */
dialog.qr { border: 0; border-radius: 18px; padding: 20px; background: var(--card); color: var(--ink); text-align: center; max-width: calc(100vw - 32px); }
dialog.qr::backdrop { background: rgba(0,0,0,.45); }
dialog.qr img { display: block; width: min(320px, 78vw); height: auto; background: #fff; border-radius: 10px; margin-bottom: 12px; }
dialog.qr form { margin: 0; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 999px; font-size: 14px; font-weight: 550;
  transition: opacity .18s, transform .18s; z-index: 10;
}
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); color: #fff; }



/* header right + sync bar */
.top-right { display: flex; gap: 8px; align-items: center; }
.syncbar {
  position: sticky; top: 0; z-index: 5; max-width: 760px; margin: 0 auto; padding: 8px 16px;
  display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; font-size: 13px; color: var(--muted);
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.ok { background: #3aa66b; box-shadow: 0 0 0 3px rgba(58,166,107,.18); }
.dot.busy { background: #d79a2b; box-shadow: 0 0 0 3px rgba(215,154,43,.2); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px rgba(179,65,47,.2); }
.online { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-left: auto; }
.person { background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; color: var(--ink); font-size: 12.5px; }
.person.me { border-color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.toolbar.bottom { margin-top: 12px; }
.who { margin-left: auto; color: var(--muted); font-size: 12px; align-self: center; }
.field { cursor: default; }
.field.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field.drop { border-color: var(--accent); border-style: dashed; }
.hint-paste { margin-top: 18px; }

/* file tiles */
.files { margin-top: 10px; display: grid; gap: 8px; justify-items: start; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; width: 100%; }
.tile { position: relative; min-width: 0; }
.tile-main { display: grid; gap: 2px; text-decoration: none; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 6px; min-width: 0; }
.tile-main:hover { border-color: var(--accent); }
.thumb { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--card); display: block; }
.thumb.icon { display: grid; place-items: center; font: 700 15px var(--mono); color: var(--accent); background: var(--accent-soft); }
.tile-name { font-size: 12.5px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-size { font-size: 11.5px; color: var(--muted); }
.tile-del { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; cursor: pointer; opacity: 0; transition: opacity .15s; }
.tile:hover .tile-del, .tile-del:focus { opacity: 1; }
@media (hover: none) { .tile-del { opacity: .85; } }

/* edit mode */
.edit-fields, .fields { list-style: none; }
.efield { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px; display: grid; gap: 8px; }
.efield.conflict { border-color: var(--danger); }
.erow { display: grid; grid-template-columns: 1fr 150px auto auto auto; gap: 6px; align-items: center; }
.erow input, .erow select { padding: 8px 10px; }
.ekey { font-weight: 600; }
.evalue { font-size: 14.5px; }
.warn { color: #b07a16; font-size: 13.5px; margin: 0; }
.conflict-box { background: var(--bg); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.conflict-box p { margin: 0 0 6px; }
.conflict-box pre { margin: 0 0 8px; white-space: pre-wrap; word-break: break-all; font-size: 13px; max-height: 200px; overflow: auto; }
.savebar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 8;
  display: flex; gap: 10px; align-items: center; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 8px 8px 8px 16px; box-shadow: 0 8px 30px rgba(0,0,0,.15); font-size: 14px;
  width: max-content; max-width: calc(100vw - 32px);
}
.savebar[hidden] { display: none; }
body:has(.savebar:not([hidden])) .board { padding-bottom: 120px; }
.dropzone { position: fixed; inset: 0; z-index: 20; pointer-events: none; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 14%, transparent); border: 3px dashed var(--accent); }
.dropzone div { background: var(--card); padding: 12px 20px; border-radius: 12px; font-weight: 600; }
.dropzone[hidden] { display: none; }

/* admin */
.board.wide { max-width: 880px; }
.newboard { display: grid; grid-template-columns: 2fr 1.4fr 1.3fr auto; gap: 8px; margin: 16px 0 24px; }
.boards { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.boards li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: grid; gap: 10px; }
.boards li.off { opacity: .6; }
.brow { display: grid; gap: 2px; }
.boards .title { font-weight: 650; color: var(--ink); text-decoration: none; font-size: 18px; }
.meta { color: var(--muted); font-size: 13.5px; }
.access-line { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; overflow-wrap: anywhere; }
.bigcode.inline { font-size: 22px; letter-spacing: .08em; }
.settings { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; border-top: 1px solid var(--line); padding-top: 10px; }
.settings select { width: auto; padding: 6px 10px; font-size: 14px; }
.row { display: flex; gap: 6px; align-items: center; font-size: 14px; }
.row input[type=checkbox] { width: auto; }

@media (max-width: 640px) {
  .newboard { grid-template-columns: 1fr; }
  .erow { grid-template-columns: 1fr auto auto auto; }
  .erow .ekey { grid-column: 1 / -1; }
  .online { margin-left: 0; }
  .who { margin-left: 0; width: 100%; }
  .savebar { left: 16px; right: 16px; transform: none; width: auto; }
  .savebar span { flex: 1; }
}
