:root {
  --bg: #0b0c0f;
  --bg-grouped: #0b0c0f;
  --card: #16181d;
  --card-2: #1e2128;
  --line: rgba(255, 255, 255, .07);
  --text: #eef0f4;
  --text-2: #9aa0ab;
  --text-3: #6b717c;
  --accent: #ffb02e;
  --accent-ink: #1a1203;
  --blue: #4c9dff;
  --green: #3ccf72;
  --red: #ff5f57;
  --radius: 14px;
  --tabbar: 58px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f2f2f6; --bg-grouped: #f2f2f6; --card: #ffffff; --card-2: #f4f4f7;
    --line: rgba(0, 0, 0, .08); --text: #111216; --text-2: #5d6370; --text-3: #8b909b;
    --accent: #e8900c; --accent-ink: #fff; color-scheme: light;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased; min-height: 100vh;
  padding: env(safe-area-inset-top) 0 calc(var(--tabbar) + env(safe-area-inset-bottom) + 24px);
}
a { color: var(--blue); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

#app { max-width: 720px; margin: 0 auto; padding: 0 16px; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 18px 2px 10px; }
.view-head h1 { font-size: 32px; line-height: 1.1; letter-spacing: -.02em; margin: 0; font-weight: 700; }
.view-head .sub { color: var(--text-2); font-size: 14px; margin-top: 4px; }
h2.section { font-size: 13px; font-weight: 600; letter-spacing: .02em; text-transform: uppercase; color: var(--text-3); margin: 26px 4px 8px; }

/* tab bar */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(20px); -webkit-backdrop-filter: saturate(160%) blur(20px);
  border-top: 1px solid var(--line);
}
#tabs[hidden], [hidden] { display: none !important; }
#tabs a { flex: 1; max-width: 120px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--text-3); font-size: 10.5px; font-weight: 500; padding: 4px 0; }
#tabs a.on { color: var(--accent); }
#tabs svg { width: 24px; height: 24px; }

/* cards & lists */
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.card + .card { margin-top: 12px; }
.pad { padding: 14px 16px; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; min-height: 52px; position: relative; width: 100%; background: none; border: 0; text-align: left; cursor: pointer; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 56px; right: 0; border-top: 1px solid var(--line); }
.row.plain + .row.plain::before { left: 16px; }
.row:active { background: var(--card-2); }
.row .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; flex: none; font-size: 16px; background: var(--card-2); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .desc { color: var(--text-2); font-size: 13.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.row .meta { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.row .chev { color: var(--text-3); font-size: 18px; }
.thumb { width: 52px; height: 52px; border-radius: 9px; object-fit: cover; flex: none; background: var(--card-2); }

/* controls */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 600; background: var(--card-2); cursor: pointer; min-height: 46px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--red); }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; }
.btn:active { transform: scale(.98); }
.btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btns.three { grid-template-columns: repeat(3, 1fr); }
textarea, input[type=text], input[type=search], input[type=number], select {
  width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.45; }
textarea:focus, input:focus, select:focus { border-color: color-mix(in srgb, var(--accent) 60%, transparent); }
.search { position: sticky; top: env(safe-area-inset-top); z-index: 5; background: var(--bg); padding: 4px 0 8px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 0; border-radius: 999px; padding: 7px 13px; background: var(--card); color: var(--text-2); font-size: 14px; font-weight: 500; cursor: pointer; }
.chip.on { background: var(--text); color: var(--bg); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.switch input { appearance: none; width: 51px; height: 31px; border-radius: 999px; background: var(--card-2); position: relative; transition: background .2s; flex: none; cursor: pointer; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 2px 4px rgba(0,0,0,.25); }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(20px); }
input[type=range] { width: 100%; accent-color: var(--accent); }

.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tile { background: var(--card); border: 0; border-radius: var(--radius); padding: 14px 10px 12px; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; cursor: pointer; min-height: 88px; justify-content: center; }
.tile .big { font-size: 24px; line-height: 1; }
.tile.on { outline: 2px solid var(--accent); }
.tile:active { background: var(--card-2); }

.day { color: var(--text-3); font-size: 13px; font-weight: 600; margin: 18px 4px 6px; }
.empty { text-align: center; color: var(--text-2); padding: 48px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.muted { color: var(--text-2); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, "SF Mono", "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); display: inline-block; }
.dot.ok { background: var(--green); } .dot.warn { background: var(--accent); } .dot.bad { background: var(--red); }
.badge { font-size: 11.5px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--card-2); color: var(--text-2); }
.badge.run { color: var(--accent); } .badge.ok { color: var(--green); } .badge.err { color: var(--red); }
.pre { white-space: pre-wrap; word-break: break-word; }
.steps { margin: 0; padding: 0 0 0 20px; color: var(--text-2); }
.steps li { margin: 6px 0; }
.steps b { color: var(--text); font-weight: 600; }
details.card > summary { list-style: none; cursor: pointer; }
details.card > summary::-webkit-details-marker { display: none; }
details.card[open] > summary .chev { transform: rotate(90deg); }
.qr { background: #fff; border-radius: 12px; padding: 10px; width: 220px; margin: 0 auto; }
.qr svg { width: 100%; height: auto; stroke: none; }
.code { font: 600 30px/1 ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .18em; text-align: center; }
.events { display: flex; flex-direction: column; gap: 6px; }
.ev { font-size: 13.5px; color: var(--text-2); }
.ev.tool { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 12px; color: var(--text-3); }
.ev.text { color: var(--text); }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 28px 16px; text-align: center; color: var(--text-2); }
.dropzone.over { border-color: var(--accent); color: var(--text); }
.hero-img { width: 100%; border-radius: var(--radius); display: block; background: var(--card); }
.progress { height: 4px; background: var(--card-2); border-radius: 4px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.banner { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius); background: color-mix(in srgb, var(--accent) 16%, var(--card)); margin: 10px 0; }

/* sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 40; opacity: 0; transition: opacity .2s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 88vh; overflow: auto; background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px 16px calc(18px + env(safe-area-inset-bottom)); transform: translateY(100%); transition: transform .25s cubic-bezier(.2,.8,.2,1); max-width: 720px; margin: 0 auto; }
.sheet .grab { width: 38px; height: 5px; border-radius: 3px; background: var(--card-2); margin: 4px auto 12px; }
.sheet.open { transform: none; }
.sheet-bg.open { opacity: 1; }
.sheet h3 { margin: 4px 0 12px; font-size: 19px; }
.sheet .actions { display: grid; gap: 8px; margin-top: 14px; }

#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 18px); transform: translate(-50%, 20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14.5px; font-weight: 500; opacity: 0; pointer-events: none; transition: all .22s; z-index: 60; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

.pair { min-height: 80vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 14px; }
.pair img { width: 84px; height: 84px; border-radius: 20px; }
.pair input { text-align: center; font: 600 28px/1 ui-monospace, Consolas, monospace; letter-spacing: .3em; max-width: 260px; }

/* desktop layout */
@media (min-width: 900px) {
  body { padding-bottom: 24px; padding-left: 220px; }
  #tabs { top: 0; bottom: 0; right: auto; width: 220px; flex-direction: column; justify-content: flex-start; padding: 24px 12px; gap: 4px; border-top: 0; border-right: 1px solid var(--line); }
  #tabs a { flex: none; max-width: none; flex-direction: row; gap: 12px; font-size: 15px; padding: 10px 12px; border-radius: 10px; color: var(--text-2); }
  #tabs a.on { background: var(--card); color: var(--text); }
  #tabs a.on svg { color: var(--accent); }
  #app { max-width: 860px; padding: 8px 32px; }
  #toast { bottom: 24px; }
  .sheet { border-radius: 18px; bottom: 50%; transform: translateY(150%); }
  .sheet.open { transform: translateY(50%); }
}
