/* machino. Design tokens from the mockups (roasthud-inspired): JetBrains Mono,
   warm near-neutral greys, coffee-brown accent. Light is the default. */

@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("vendor/jetbrains-mono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 100 800;
  font-display: swap;
  src: url("vendor/jetbrains-mono-latin-ext.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #fafaf8; --card: #ffffff; --muted: #f1f0ec; --sel: #ebe9e3; --line: #e3e2dc;
  --fg: #12110e; --dim: #55544f; --faint: #6b6a64;
  --acc: #7a4a22; --acc-ink: #ffffff; --accsoft: rgba(122, 74, 34, .10);
  --warn: #b5541c; --ok: #23864f; --shadow: 0 12px 32px rgba(0, 0, 0, .08);
  --radius: 10px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b0b09; --card: #151513; --muted: #1f1f1c; --sel: #262622; --line: rgba(255, 255, 245, .10);
  --fg: #f7f7f4; --dim: #b0afa8; --faint: #8a8982;
  --acc: #e2b97c; --acc-ink: #1c1307; --accsoft: rgba(226, 185, 124, .14);
  --warn: #f0904f; --ok: #7fd3a0; --shadow: 0 12px 32px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="auto"] {
    --bg: #0b0b09; --card: #151513; --muted: #1f1f1c; --sel: #262622; --line: rgba(255, 255, 245, .10);
    --fg: #f7f7f4; --dim: #b0afa8; --faint: #8a8982;
    --acc: #e2b97c; --acc-ink: #1c1307; --accsoft: rgba(226, 185, 124, .14);
    --warn: #f0904f; --ok: #7fd3a0; --shadow: 0 12px 32px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font: 13px/1.45 "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
h1, h2 { margin: 0; }
ul { list-style: none; margin: 0; padding: 0; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.lbl { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 500; }
.lbl.warn { color: var(--warn); }
.lbl.acc, .acc { color: var(--acc); }
.muted { color: var(--faint); font-size: 12px; }
kbd { border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; font: 11px/18px inherit; color: var(--dim); background: var(--card); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; display: inline-block; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 12px; text-decoration: none; background: var(--card); }
.chip.on { border-color: var(--acc); color: var(--acc); }
.chip.acc { border-color: var(--acc); }
.pill { display: inline-block; border-radius: 999px; padding: 0 8px; font-size: 11px; background: var(--muted); color: var(--dim); }
.btn { border: 1px solid var(--line); border-radius: 8px; padding: 7px 12px; background: var(--card); }
.btn.pri { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); font-weight: 600; }
.btn.danger { color: var(--warn); }
.btn.small { padding: 3px 9px; font-size: 12px; }
.icon-btn { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; color: var(--faint); border: 0; background: none; text-decoration: none; }
.icon-btn:hover { background: var(--sel); color: var(--fg); }
.kbd-btn { border: 0; background: none; padding: 0; }
.notice { border: 1px solid var(--warn); border-radius: 8px; padding: 10px 12px; color: var(--fg); background: var(--accsoft); margin: 0; }
.notice.ok { border-color: var(--ok); }
.notice p { margin: 4px 0 8px; color: var(--dim); }
.empty { color: var(--faint); padding: 28px 12px; }

/* layout: nav · main · detail; wraps to one column on narrow screens */
.app { display: flex; flex-wrap: wrap; min-height: 100vh; min-height: 100dvh; }
.nav {
  flex: 1 1 220px; max-width: 260px; padding: 20px 14px; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.nav > a { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 8px; text-decoration: none; color: var(--dim); }
.nav > a:hover { background: var(--muted); }
.nav > a.on { background: var(--sel); color: var(--fg); }
.nav .n { margin-left: auto; font-size: 11px; color: var(--faint); white-space: nowrap; }
.nav-h { padding: 20px 10px 6px; }
.brand { display: flex; align-items: baseline; gap: 8px; padding: 0 10px 18px; text-decoration: none; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -.02em; }
.brand-tag { font-size: 11px; color: var(--faint); }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px 5px 10px; margin-bottom: 14px; color: var(--faint); background: var(--card); }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; color: var(--fg); padding: 2px 0; }
.tagcloud { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px; }
.nav-foot { margin-top: auto; padding: 14px 10px 0; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--accsoft); color: var(--acc); display: grid; place-items: center; font-weight: 700; font-size: 12px; }

.main { flex: 999 1 560px; min-width: 0; padding: 24px 28px 64px; max-width: 980px; }
.head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.head h1 { margin-top: 4px; font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.sync { font-size: 11px; color: var(--faint); }
.sync.bad { color: var(--warn); }

.hud { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.tile { flex: 1 1 120px; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; background: var(--card); }
.tile b { display: block; font-size: 28px; font-weight: 600; line-height: 1.1; letter-spacing: -.02em; }
.tile b.warn { color: var(--warn); }

.bars { display: flex; align-items: flex-end; gap: 6px; height: 96px; margin-top: 18px; padding: 12px 14px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 10.5px; color: var(--faint); }
.bar i { display: block; width: 100%; max-width: 26px; background: var(--muted); border-radius: 4px 4px 0 0; }
.bar.on i { background: var(--acc); }
.bar.on { color: var(--fg); }

.quickadd { display: flex; align-items: center; gap: 12px; margin-top: 18px; border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); padding: 10px 14px; }
.quickadd:focus-within { border-color: var(--acc); }
.quickadd input { flex: 1; min-width: 0; border: 0; outline: 0; background: none; padding: 2px 0; }
.plus { color: var(--acc); font-weight: 700; }

.bulkbar { position: sticky; top: 8px; z-index: 5; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; padding: 8px 12px; border: 1px solid var(--acc); border-radius: var(--radius); background: var(--card); box-shadow: var(--shadow); }
.bulkbar[hidden] { display: none; }
.bulkbar button { border: 1px solid var(--line); border-radius: 8px; padding: 4px 10px; background: var(--card); }
.bulkbar .danger { color: var(--warn); }

.sec-h { display: flex; align-items: baseline; gap: 10px; padding: 18px 12px 6px; font-weight: 400; }
.row { position: relative; display: flex; align-items: flex-start; gap: 12px; padding: 10px 12px; border-radius: 8px; }
.row:hover { background: var(--muted); }
.row.sel { background: var(--sel); outline: 1px solid var(--line); }
.row.cursor { outline: 2px solid var(--acc); outline-offset: -2px; }
.pick { position: absolute; left: -18px; top: 13px; margin: 0; opacity: 0; accent-color: var(--acc); }
.row:hover .pick, .pick:checked, .pick:focus-visible, body.picking .pick { opacity: 1; }
.chk { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--faint); background: none; flex: none; margin-top: 1px; padding: 0; position: relative; }
.chk:hover:not(:disabled) { border-color: var(--acc); }
.chk.done { background: var(--acc); border-color: var(--acc); }
.chk.done::after { content: ""; position: absolute; left: 5px; top: 2px; width: 4px; height: 8px; border: solid var(--acc-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.chk.cancelled { border-style: dashed; }
.chk.prog { background: conic-gradient(var(--acc) 0 var(--p), transparent var(--p) 100%); }
.chk.big { width: 22px; height: 22px; margin-top: 5px; }
.chk.big.done::after { left: 6px; top: 3px; width: 5px; height: 10px; }
.chk.small { width: 15px; height: 15px; }
.chk.small.done::after { left: 4px; top: 1px; width: 3px; height: 7px; }
.chk:disabled { opacity: .5; cursor: default; }
.rmain { flex: 1; min-width: 0; text-decoration: none; display: flex; flex-direction: column; }
.rtitle { overflow-wrap: anywhere; }
.rtitle.done, .done { color: var(--faint); text-decoration: line-through; }
.rmeta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 11.5px; color: var(--faint); margin-top: 2px; }
.rmeta > :not(.dot):not(:first-child):not(.dot + *)::before { content: "· "; }
.prio { color: var(--warn); font-weight: 700; margin-right: 6px; text-decoration: none; display: inline-block; }
.due { font-size: 12px; color: var(--dim); white-space: nowrap; }
.due.late { color: var(--warn); }

/* detail pane */
.detail {
  flex: 1 1 360px; max-width: 460px; border-left: 1px solid var(--line); background: var(--card);
  padding: 22px 24px 28px; display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; align-self: flex-start; max-height: 100vh; overflow-y: auto;
}
.detail.empty-detail { display: none; }
.d-top { display: flex; align-items: center; gap: 8px; }
.d-head { display: flex; gap: 12px; align-items: flex-start; }
.d-title { display: block; width: 100%; margin: 0; padding: 2px 0; border: 0; border-radius: 4px; background: none; resize: none; overflow: hidden; font-size: 21px; font-weight: 600; letter-spacing: -.02em; line-height: 1.3; }
.d-title:focus { outline: 1px solid var(--line); background: var(--bg); }
.parent { font-size: 12px; color: var(--faint); text-decoration: none; }
.props { border: 0; padding: 0; margin: 0; min-width: 0; }
.prop { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); align-items: center; }
.prop input[type=text], .prop input[type=url], .prop input[type=date], .prop input[type=time], .prop select {
  width: 100%; min-width: 0; border: 1px solid transparent; border-radius: 6px; padding: 4px 6px; background: none;
}
.prop input:hover, .prop select:hover { border-color: var(--line); }
.prop input:focus, .prop select:focus { border-color: var(--acc); outline: 0; background: var(--bg); }
.inputs { display: flex; gap: 6px; align-items: center; min-width: 0; }
.inputs input[type=date] { flex: 1 1 140px; }
.inputs input[type=time] { flex: 0 1 120px; }
.inputs { flex-wrap: wrap; }
.inputs input[type=range] { flex: 1; accent-color: var(--acc); }
.seg { display: flex; flex-wrap: wrap; gap: 4px; }
.seg label { border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--faint); cursor: pointer; }
.seg label.on { border-color: var(--acc); background: var(--accsoft); color: var(--acc); font-weight: 600; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label:focus-within { outline: 2px solid var(--acc); }
.sub-h { display: flex; justify-content: space-between; align-items: baseline; }
.progress { height: 3px; background: var(--muted); border-radius: 2px; margin: 8px 0 6px; }
.progress i { display: block; height: 3px; background: var(--acc); border-radius: 2px; }
.sub { display: flex; gap: 10px; align-items: center; padding: 5px 0; }
.sub a { flex: 1; text-decoration: none; }
.sub.add input { flex: 1; border: 0; background: none; outline: 0; padding: 2px 0; }
.notes { display: flex; flex-direction: column; gap: 6px; }
.notes textarea { width: 100%; border: 1px solid transparent; border-radius: 6px; padding: 6px; background: none; color: var(--dim); resize: vertical; min-height: 4em; }
.notes textarea:hover { border-color: var(--line); }
.notes textarea:focus { border-color: var(--acc); outline: 0; background: var(--bg); color: var(--fg); }
.raw { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; font-size: 11.5px; }
.raw summary { cursor: pointer; }
.raw pre { margin: 8px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--dim); font: inherit; }
.d-foot { margin-top: auto; display: flex; gap: 10px; align-items: center; font-size: 11px; color: var(--faint); }

/* toasts */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 20; width: max-content; max-width: calc(100vw - 32px); }
.toast { display: flex; gap: 14px; align-items: center; padding: 10px 14px; border-radius: var(--radius); background: var(--fg); color: var(--bg); box-shadow: var(--shadow); }
.toast button { border: 0; background: none; color: var(--acc); font-weight: 700; padding: 0; }
:root[data-theme="light"] .toast button { color: #e2b97c; }

/* help dialog */
.help { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--fg); padding: 20px 24px; max-width: 460px; }
.help::backdrop { background: rgba(0, 0, 0, .3); }
.help dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 14px 0; }
.help dt { white-space: nowrap; }
.help dd { margin: 0; color: var(--dim); }

/* settings, login */
.settings { display: flex; flex-direction: column; gap: 18px; }
.cards { display: flex; flex-direction: column; gap: 12px; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; }
.card-h { display: flex; align-items: baseline; gap: 10px; font-size: 15px; font-weight: 600; }
.state { font-size: 12px; font-weight: 400; }
.state.ok { color: var(--ok); }
.state.bad { color: var(--warn); }
.listrows li { display: flex; gap: 12px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.listrows li:last-child { border-bottom: 0; }
.listrows a { text-decoration: none; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field input, .field select { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg); }
.pair { display: flex; flex-wrap: wrap; gap: 18px; align-items: flex-start; }
.pair-form { flex: 1 1 260px; display: flex; flex-direction: column; gap: 12px; }
.btns { display: flex; gap: 8px; flex-wrap: wrap; }
.qr { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; border: 1px dashed var(--line); border-radius: var(--radius); padding: 14px; }
.qr[hidden] { display: none; }
.qr canvas { background: #fff; border-radius: 6px; padding: 8px; image-rendering: pixelated; }
.qr dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; font-size: 12px; }
.qr dd { margin: 0; overflow-wrap: anywhere; }
.prefs { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 8px; }
.login .brand { padding: 0 4px 8px; }
.login h1 { font-size: 22px; letter-spacing: -.02em; }
.login .btn { margin-top: 4px; }

/* narrow screens: one column; the detail opens as a sheet over the list */
@media (max-width: 760px) {
  .nav { max-width: none; flex-basis: 100%; border-right: 0; border-bottom: 1px solid var(--line); flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 12px 8px; gap: 4px; }
  .nav .brand { padding: 0 6px 0 0; flex: 1 0 100%; }
  .nav .search { flex: 1 0 100%; margin: 6px 0; }
  .nav > a { padding: 5px 9px; }
  .nav > a .n { margin-left: 4px; }
  .nav-h, .tagcloud { display: none; }
  .nav-foot { display: none; }
  .main { padding: 16px 16px 72px; }
  .head h1 { font-size: 26px; }
  .hud { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile { padding: 8px 10px; }
  .tile b { font-size: 22px; }
  .pick { display: none; }
  .detail { position: fixed; inset: auto 0 0 0; max-width: none; max-height: 88dvh; border: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; box-shadow: var(--shadow); z-index: 10; }
}
