:root {
    --bg: #101820;
    --panel: #17222c;
    --border: #2c3c48;
    --text: #e4edf1;
    --muted: #9bafb9;
    --accent: #71d9bd;
    --ok: #3fb96b;
    --warn: #e5a13c;
    --danger: #e05252;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--bg);
    color: var(--text);
}

main { max-width: 1100px; margin: 0 auto; padding: 20px; }
.footer { text-align: center; color: var(--muted); padding: 24px; font-size: 12px; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 18px 0 10px; }

code {
    background: #0d1017;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 13px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 10px 24px;
}
.topbar nav { display: flex; align-items: center; gap: 16px; }
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.brand span { color: var(--accent); }
.spacer { flex: 1; }

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 16px;
}
.page-head h1 a { color: var(--text); }

.badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    border-radius: 4px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    background: #232a38;
    color: var(--muted);
    vertical-align: middle;
}
.status-active { color: var(--ok); border-color: var(--ok); }
.status-stopped { color: var(--danger); border-color: var(--danger); }
.status-error { color: var(--warn); border-color: var(--warn); }
.badge-off { color: var(--danger); }
.access-public { color: var(--danger); border-color: var(--danger); }
.access-lan { color: var(--warn); border-color: var(--warn); }
.access-tailscale { color: #b48cf2; border-color: #b48cf2; }

.cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.card h2 { margin: 0; font-size: 17px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: auto; }

.meta {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 12px;
    margin: 0;
    font-size: 13px;
}
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.two-col { grid-template-columns: 160px 1fr; }

.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 18px;
    margin-bottom: 16px;
}
.danger-zone { border-color: rgba(224, 82, 82, .4); }

.btn {
    display: inline-block;
    background: #26303f;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
}
.btn:hover { background: #2e3a4d; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3f8ce8; }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(224, 82, 82, .12); }
.btn-ghost { background: transparent; }

.inline-form { display: inline; }
.link-btn {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: inherit;
    padding: 0;
}

.flash {
    background: rgba(63, 185, 107, .12);
    border: 1px solid var(--ok);
    border-radius: 6px;
    padding: 10px 14px;
    margin: 0 auto 16px;
    max-width: 1060px;
}
.flash-error { background: rgba(224, 82, 82, .12); border-color: var(--danger); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }
.row-dir td { background: rgba(79, 156, 249, .04); }
.nowrap { white-space: nowrap; }

.breadcrumb { margin-bottom: 12px; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }

.file-content {
    background: #0d1017;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    font: 13px/1.55 ui-monospace, "Cascadia Code", Menlo, monospace;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 70vh;
    overflow-y: auto;
}
.log-content { white-space: pre; }

.form-grid label { display: block; margin-bottom: 14px; }
.form-grid input[type=text],
.form-grid input[type=url],
.form-grid input[type=number],
.form-grid input[type=password],
.form-grid textarea {
    width: 100%;
    max-width: 560px;
    background: #0d1017;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    margin-top: 4px;
}
.form-grid fieldset {
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 14px;
    max-width: 560px;
}
.form-grid fieldset legend { font-size: 12px; color: var(--muted); padding: 0 6px; }
.form-grid fieldset label { margin-bottom: 4px; }
.checkbox input { margin-right: 6px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }
.field-row { display: flex; gap: 10px; align-items: flex-end; }
.field-row .grow { flex: 1; }
.browse-btn { white-space: nowrap; margin-bottom: 14px; }

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
}
.modal[hidden], .modal-backdrop[hidden] { display: none; }
.modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    width: min(560px, 92vw);
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    padding: 16px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.browse-list {
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #0d1017;
    min-height: 200px;
    max-height: 45vh;
}
.browse-item {
    display: block;
    padding: 8px 12px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.browse-item:hover { background: #232a38; text-decoration: none; color: var(--accent); }
.modal-actions { display: flex; gap: 10px; margin-top: 14px; justify-content: flex-end; }

.upload-panel { margin-bottom: 16px; }
.upload-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    transition: border-color .15s, background .15s;
}
.upload-zone.over { border-color: var(--accent); background: rgba(79,156,249,.08); }
#upload-progress { margin-top: 10px; font-size: 13px; }
.upload-row { padding: 2px 0; color: var(--muted); }
#upload-progress strong { color: var(--text); }
.btn-sm { padding: 3px 10px; font-size: 12px; }
.form-grid select {
    width: 100%;
    max-width: 560px;
    background: #0d1017;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    margin-top: 4px;
}
h3 { font-size: 14px; margin: 16px 0 10px; }

.editor-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 14px;
}
.editor-box summary { cursor: pointer; color: var(--accent); font-size: 14px; }
.editor-textarea {
    width: 100%;
    margin-top: 10px;
    background: #0d1017;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px;
    font: 13px/1.5 ui-monospace, "Cascadia Code", Menlo, monospace;
    resize: vertical;
}
.discover-panel { border-color: rgba(79,156,249,.4); }
.discover-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.text-ok { color: var(--ok); }
.text-warn { color: var(--warn); }
.muted { color: var(--muted); font-size: 13px; }
.empty { color: var(--muted); padding: 32px 0; text-align: center; }

.login-body { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 36px;
    width: 340px;
}
.login-box h1 { text-align: center; margin-bottom: 20px; }
.login-box label { display: block; margin-bottom: 14px; font-size: 13px; }
.login-box input {
    width: 100%;
    margin-top: 4px;
    background: #0d1017;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 10px;
    font: inherit;
}
.login-box button {
    width: 100%;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px;
    font: inherit;
    cursor: pointer;
    margin-top: 6px;
}

/* MiniHub: a compact, touch-friendly workspace. */
:root { color-scheme: dark; --input: #101a23; }
[hidden] { display: none !important; }
body { -webkit-text-size-adjust: 100%; }
main { max-width: 1200px; padding: 34px 28px; min-width: 0; }
h1 { font-size: clamp(25px, 3vw, 34px); letter-spacing: -.035em; line-height: 1.2; margin-bottom: 8px; }
h2 { letter-spacing: -.015em; }
p { margin: 8px 0 12px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
button, input, select, textarea { font: inherit; }
button, a, summary { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { min-width: 0; }
.topbar { padding: 14px max(28px, calc((100vw - 1144px) / 2)); gap: 28px; }
.brand { display: inline-flex; align-items: center; font-size: 22px; letter-spacing: -.04em; flex-shrink: 0; }
.brand img { margin-right: 10px; }
.topbar nav { flex: 1; gap: 6px; }
.topbar nav a { color: var(--muted); padding: 10px 12px; border-radius: 8px; font-size: 14px; white-space: nowrap; }
.topbar nav a:hover, .topbar nav a[aria-current] { background: #22343e; color: var(--text); text-decoration: none; }
.topbar nav a[aria-current] { color: var(--accent); }
.eyebrow { color: var(--accent); font-size: 11px; letter-spacing: .15em; font-weight: 700; margin: 0 0 12px; }
.page-head .muted { font-size: 15px; }
.page-head { margin-bottom: 24px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 44px; padding: 9px 14px; border-radius: 9px; font-weight: 600; font-size: 13px; }
.btn-primary { color: #092e25; }
.btn-primary:hover { background: #99e7d1; border-color: #99e7d1; }
.btn-ghost:hover { background: #22343e; }
.overview { display: flex; flex-wrap: wrap; align-items: center; gap: 24px; padding-bottom: 24px; margin-bottom: 24px; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.overview > span, .overview > a { display: inline-flex; gap: 8px; align-items: center; }
.overview strong { color: var(--text); font-size: 18px; font-variant-numeric: tabular-nums; }
.overview > a { margin-left: auto; color: var(--muted); }
.status-dot { width: 7px; height: 7px; background: var(--accent); border-radius: 50%; }
.search-row { display: flex; align-items: center; gap: 18px; }
.search-field { flex: 1; display: flex; align-items: center; gap: 12px; padding: 0 15px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.search-field:focus-within { border-color: var(--accent); }
.search-field > span[aria-hidden] { font-size: 27px; color: var(--muted); }
.search-field input { flex: 1; width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); padding: 14px 0; font-size: 16px; }
.search-field kbd { font: 12px ui-monospace, monospace; border: 1px solid var(--border); border-radius: 4px; padding: 2px 6px; color: var(--muted); }
.profile-field { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
select, .share-dialog input { background: var(--input); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 11px 12px; }
.filter-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; }
.filter-tabs { display: flex; gap: 6px; }
.filter-tab { border: 1px solid transparent; border-radius: 8px; background: transparent; color: var(--muted); padding: 9px 13px; cursor: pointer; min-height: 44px; font-size: 13px; }
.filter-tab[aria-pressed=true] { color: var(--accent); border-color: #396655; background: #1b342f; }
.context-hint { margin: 14px 0 20px; }
.cards { grid-template-columns: repeat(auto-fill, minmax(min(100%, 305px), 1fr)); gap: 18px; align-items: start; }
.card { border-radius: 14px; padding: 22px; gap: 16px; min-width: 0; }
.app-card { transition: border-color .15s; }
.app-card:hover { border-color: #547065; }
.card h2 { font-size: 20px; }
.card h2 a { color: var(--text); }
.app-monogram { display: flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 12px; font-size: 23px; font-weight: 700; background: #254940; color: #9eebd3; }
.app-card:nth-child(3n+2) .app-monogram { background: #263e55; color: #a3d3f7; }
.app-card:nth-child(3n+3) .app-monogram { background: #423849; color: #dfb9ec; }
.favorite-button { font-size: 25px; line-height: 1; min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--muted); cursor: pointer; border-radius: 9px; }
.favorite-button[aria-pressed=true] { color: #f0c96d; }
.favorite-button:hover { background: #253540; }
.app-address { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; margin: 6px 0 0; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.card .badges { margin: 0; }
.badge { border-radius: 6px; font-size: 10px; padding: 3px 7px; letter-spacing: .02em; }
.badge-enabled { color: #91dfb7; background: #1c382e; border-color: #2c5b42; }
.badge-access-lan, .badge-access-local { color: #bbccd4; background: #243540; }
.badge-access-tailscale { color: #ccb5ef; border-color: #5e4a7b; }
.badge-access-public { color: #f1c581; border-color: #735936; }
.card-actions { align-items: center; }
.open-app { flex: 1; }
.app-details { border-top: 1px solid var(--border); padding-top: 12px; font-size: 12px; color: var(--muted); }
summary { cursor: pointer; min-height: 36px; padding: 8px 0; }
.app-details .meta { margin: 10px 0; font-size: 12px; }
.app-details code { font-size: 11px; }
.panel { border-radius: 12px; padding: 22px; min-width: 0; }
.panel > h2:first-child { margin-top: 0; }
.status-note { font-size: 12px; margin: 18px 0 28px; }
.access-banner { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px; border: 1px solid #345748; background: #162e28; border-radius: 12px; color: var(--text); margin: 24px 0; }
.access-banner:hover { text-decoration: none; border-color: var(--accent); }
.access-banner > span:last-child { font-size: 28px; color: var(--accent); }
.discover-panel summary { color: var(--muted); }
.access-guide { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 12px; }
.step-number { color: var(--accent); font: 12px ui-monospace, monospace; }
.access-guide h2 { font-size: 19px; }
.url-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 20px; }
.form-grid input[type=text], .form-grid input[type=url], .form-grid input[type=number], .form-grid input[type=password], .form-grid textarea, .form-grid select { background: var(--input); padding: 11px 12px; border-radius: 8px; }
.save-bar { position: sticky; bottom: 12px; padding: 14px 18px; margin: 10px 0 26px; border: 1px solid var(--border); background: #1c2b35; border-radius: 12px; align-items: center; box-shadow: 0 8px 28px #0004; }
.access-help ol { padding-left: 24px; }
.access-help li { padding: 5px 0; }
.access-help { margin-top: 22px; }
.share-dialog { width: min(470px, calc(100vw - 28px)); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: 0 24px 100px #0008; }
.share-dialog::backdrop { background: #050b12bb; backdrop-filter: blur(4px); }
.share-dialog h2 { margin: 0; font-size: 20px; }
.share-dialog label:not(.sr-only) { display: block; margin: 18px 0 6px; font-size: 13px; color: var(--muted); }
.share-dialog select, .share-dialog input { width: 100%; }
.share-dialog input { font-size: 13px; }
.qr-container { text-align: center; }
#share-qr { max-width: min(100%, 260px); height: auto; margin: 8px auto 20px; image-rendering: pixelated; border-radius: 4px; }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 32px); border: 1px solid var(--accent); background: #203e33; color: var(--text); padding: 14px 20px; border-radius: 10px; z-index: 100; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -80px; left: 20px; z-index: 200; background: var(--panel); padding: 12px; }
.skip-link:focus { top: 10px; }
.table-scroll { width: 100%; overflow-x: auto; margin-bottom: 12px; }
.table-scroll .table { min-width: 540px; }
.meta dd { min-width: 0; }
.footer a { margin-left: 14px; }
.login-box { width: min(400px, calc(100vw - 32px)); padding: 32px; min-height: auto; }
.login-box h1 { margin-bottom: 6px; }
.login-box h1 span { color: var(--accent); }
.login-intro { text-align: center; margin-bottom: 26px; }
.login-box input { font-size: 16px; min-height: 46px; }
.login-box button { color: #092e25; font-weight: 700; min-height: 46px; }
@media (max-width: 900px) {
    .topbar { flex-wrap: wrap; gap: 10px; padding: 12px 24px 0; }
    .topbar nav { order: 3; width: 100%; flex: auto; overflow-x: auto; padding: 4px 0 10px; }
    .logout-form { margin-left: auto; }
    .access-guide { grid-template-columns: 1fr; gap: 0; }
    .url-grid { grid-template-columns: 1fr; gap: 0; }
}
@media (max-width: 600px) {
    main { padding: 24px 16px; }
    .topbar { padding: 10px 16px 0; }
    .topbar nav { gap: 2px; }
    .topbar nav a { font-size: 12px; padding: 11px 9px; }
    .brand { font-size: 20px; }
    .logout-form .btn { font-size: 11px; padding: 8px; }
    .dashboard-head { align-items: start; }
    .dashboard-head > .btn { min-height: 40px; }
    .overview { gap: 10px 18px; padding-bottom: 20px; }
    .overview > a { margin-left: 0; }
    .overview strong { font-size: 16px; }
    .search-row { flex-direction: column; align-items: stretch; gap: 12px; }
    .profile-field { justify-content: space-between; }
    .profile-field select { flex: 1; max-width: 220px; font-size: 16px; }
    .search-field kbd { display: none; }
    .filter-row { flex-wrap: wrap; }
    .filter-tabs { width: 100%; gap: 3px; }
    .filter-tab { flex: 1; padding: 9px 7px; font-size: 12px; white-space: nowrap; }
    .card, .panel { padding: 18px; }
    .cards { grid-template-columns: minmax(0, 1fr); }
    .card h2 { font-size: 21px; }
    .form-grid input, .form-grid select, .form-grid textarea, .share-dialog input, .share-dialog select { font-size: 16px !important; }
    .field-row { flex-wrap: wrap; }
    .field-row .grow { min-width: 100%; }
    .two-col { grid-template-columns: 1fr; gap: 2px; }
    .two-col dd { margin-bottom: 10px; }
    .form-actions { flex-wrap: wrap; }
    .save-bar { position: static; padding: 14px; }
    .save-bar .btn { width: 100%; }
    .page-head > div { min-width: 0; }
    .page-head h1 { overflow-wrap: anywhere; }
    .share-dialog { padding: 20px; }
    .btn-sm, .link-btn { min-height: 44px; }
    .footer { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; } }
