:root {
    color-scheme: light dark;
    --bg: light-dark(#f5f5f1, #131412);
    --surface: light-dark(#ffffff, #1b1c1a);
    --surface-2: light-dark(#efefe9, #262724);
    --line: light-dark(#dfdfd7, #32332f);
    --text: light-dark(#1b1c19, #ededE7);
    --muted: light-dark(#63645c, #a3a499);
    --accent: light-dark(#17604a, #86d6b6);
    --on-accent: light-dark(#ffffff, #0e241c);
    --danger: light-dark(#a3301d, #ff9d8b);
    --radius: 8px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { font: 14px/1.45 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
body { margin: 0; min-width: 320px; background: var(--bg); color: var(--text); }
h2, h3, p { margin: 0; }
code { font: 12px ui-monospace, SFMono-Regular, Consolas, monospace; color: var(--muted); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.wrap { width: min(1180px, 100%); margin-inline: auto; padding-inline: 16px; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); font-weight: 600; text-decoration: none; white-space: nowrap; cursor: pointer; }
.btn:hover { background: var(--surface-2); }
.btn-small { min-height: 30px; padding: 0 10px; font-size: 13px; }
.btn-primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent); filter: brightness(1.12); }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.input { width: 100%; min-height: 36px; padding: 7px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
textarea.input { resize: vertical; }

.topbar { border-bottom: 1px solid var(--line); background: var(--surface); }
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; }
.topbar-actions { display: flex; align-items: center; gap: 6px; }
.logo { color: var(--text); font-size: 16px; font-weight: 700; text-decoration: none; }

.notice { margin-top: 16px; padding: 10px 12px; border: 1px solid; border-radius: var(--radius); }
.notice-success { color: var(--accent); }
.notice-error { color: var(--danger); }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin: 20px 0 14px; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 6px 10px; border-radius: var(--radius); color: var(--muted); font-weight: 600; text-decoration: none; }
.tabs a:hover { color: var(--text); }
.tabs a[aria-current] { background: var(--surface-2); color: var(--text); }
.tabs span { margin-left: 3px; font-weight: 400; }
.summary { color: var(--muted); font-size: 13px; }
.summary strong { color: var(--text); }
.search { width: 220px; margin-left: auto; }

.projects { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); border-spacing: 0; background: var(--surface); }
.projects th { padding: 10px 14px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 12px; font-weight: 600; text-align: left; white-space: nowrap; }
.projects td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.projects tbody tr:last-child td { border-bottom: 0; }
.projects tr:target td { animation: highlight 1.8s ease-out; }
@keyframes highlight { from { background: var(--surface-2); } }
@media (prefers-reduced-motion: reduce) { .projects tr:target td { animation: none; } }

.col-name { width: 100%; max-width: 0; }
.col-name strong { display: block; overflow: hidden; font-size: 15px; text-overflow: ellipsis; white-space: nowrap; }
.note { overflow: hidden; margin-top: 3px; color: var(--muted); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.col-quote { font-variant-numeric: tabular-nums; white-space: nowrap; }
.col-actions { white-space: nowrap; }
.col-actions .btn + .btn { margin-left: 4px; }
.share-on { display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; flex: none; border-radius: 50%; background: var(--accent); }

.status { --tone: var(--muted); appearance: none; min-height: 30px; padding: 0 26px 0 10px; border: 1px solid color-mix(in srgb, var(--tone) 35%, transparent); border-radius: 999px; background-color: color-mix(in srgb, var(--tone) 11%, transparent); background-image: linear-gradient(45deg, transparent 50%, var(--tone) 50%), linear-gradient(135deg, var(--tone) 50%, transparent 50%); background-position: right 14px center, right 10px center; background-repeat: no-repeat; background-size: 4px 4px; color: var(--tone); font-size: 13px; font-weight: 600; cursor: pointer; }
.status option { background: var(--surface); color: var(--text); }
.status-building { --tone: light-dark(#1f5fa8, #8fbdf5); }
.status-ready { --tone: light-dark(#0a6a72, #6fd3da); }
.status-waiting { --tone: light-dark(#855200, #f0bd62); }
.status-accepted { --tone: var(--accent); }

.empty { padding: 48px 16px; border: 1px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: center; }
#no-results { margin-top: 10px; }

dialog { width: min(520px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / .5); }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; }
.dialog-head h2 { overflow-wrap: anywhere; font-size: 17px; }
.dialog-section { padding: 16px 18px; border-top: 1px solid var(--line); }
.dialog-section h3 { font-size: 13px; }
.stack { display: grid; gap: 12px; }
.field { display: grid; gap: 5px; font-size: 13px; font-weight: 600; }
.field .input { font-weight: 400; }
.share-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.command { display: grid; gap: 4px; color: var(--muted); font-size: 13px; }
.command > div { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 6px 6px 10px; border-radius: var(--radius); background: var(--surface-2); }
.command code { min-width: 0; color: var(--text); overflow-wrap: anywhere; }

.login { display: grid; min-height: 100dvh; place-items: center; padding: 16px; }
.login-card { display: grid; gap: 18px; width: min(360px, 100%); padding: 26px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.login-card h1 { margin: 0; font-size: 20px; }
.login-card .notice { margin: 0; }
.login-card .btn { width: 100%; }

@media (max-width: 920px) {
    .search { width: 100%; margin-left: 0; }
    .projects, .projects tbody { display: block; border: 0; background: none; }
    .projects thead { display: none; }
    .projects tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; margin-bottom: 10px; padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
    .projects td, .projects tbody tr:last-child td { display: block; padding: 0; border: 0; }
    .col-name, .col-share, .col-actions { grid-column: 1 / -1; width: auto; max-width: none; }
    .projects td.col-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
    .col-actions .btn + .btn { margin-left: 0; }
}

@media (pointer: coarse) {
    .btn, .btn-small, .status, .input { min-height: 44px; }
}
