/* Guardian Vault on the web: the app's dark palette and green accent (as the admin dashboard). */

:root {
    --bg: #0f1015;
    --surface: #16171e;
    --surface-2: #1c1e26;
    --surface-3: #23252f;
    --border: #262834;
    --border-strong: #343744;
    --text: #eceef3;
    --text-muted: #9a9fae;
    --text-faint: #6b7080;
    --accent: #96e6a1;
    --accent-strong: #b4f0bc;
    --accent-ink: #0e1a11;
    --accent-soft: rgba(150, 230, 161, 0.12);
    --warn: #f2c46d;
    --warn-soft: rgba(242, 196, 109, 0.13);
    --bad: #ff8080;
    --radius-lg: 14px;
    --radius: 10px;
    --radius-sm: 7px;
    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    --mono: "Cascadia Mono", "Cascadia Code", Consolas, ui-monospace, monospace;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
#app { height: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.muted { color: var(--text-muted); }
.small { font-size: 12.5px; }
.mono { font-family: var(--mono); }
.status { min-height: 1.5em; margin: 6px 0; color: var(--text-muted); }
.alert { margin: 0 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); border: 1px solid rgba(242, 196, 109, 0.3); }
.unreadable { color: var(--warn); }
.empty { padding: 18px 4px; }

/* Buttons and fields */
.btn { border: 1px solid var(--border-strong); background: var(--surface-2); border-radius: var(--radius-sm); padding: 7px 14px; cursor: pointer; }
.btn:hover { background: var(--surface-3); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-secondary { background: var(--surface-3); }
.btn-small { padding: 3px 10px; font-size: 12.5px; }
.btn-danger { background: rgba(255, 128, 128, 0.14); border-color: rgba(255, 128, 128, 0.45); color: var(--bad); font-weight: 600; }
.btn-danger:hover { background: rgba(255, 128, 128, 0.24); }
input[type="text"], input[type="password"], input[type="search"], select, textarea {
    width: 100%; padding: 8px 11px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2);
}
textarea { resize: vertical; min-height: 5.5em; }
input[type="checkbox"] { accent-color: var(--accent); margin: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Signing in and unlocking */
.auth { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; }
.auth-brand h1 { margin: 10px 0 2px; font-size: 22px; }
.auth-brand p { margin: 0 0 18px; }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px; background: var(--surface-3); color: var(--accent); font: 700 16px var(--mono); }
.field { margin-bottom: 12px; }
.field label { display: block; margin-bottom: 4px; color: var(--text-muted); }
.actions { display: flex; gap: 8px; margin-top: 6px; }
.auth-notes { margin: 20px 0 0; padding-left: 18px; color: var(--text-faint); font-size: 12.5px; }

/* The open vault fills the window: the page itself never scrolls; the folders, the list and the entry each do. */
.vault { display: flex; flex-direction: column; height: 100%; height: 100dvh; overflow: hidden; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar .brand { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.brand-name { display: block; font-weight: 600; }
.brand-sub { display: block; color: var(--text-muted); font-size: 12px; }
.topbar #search { flex: 1; max-width: 520px; }
.topbar select { width: auto; }
.top-actions { display: flex; gap: 6px; margin-left: auto; }
.vault > .status { padding: 0 16px; margin: 4px 0; }
.columns { flex: 1; min-height: 0; display: grid; grid-template-columns: 230px minmax(260px, 380px) 1fr; grid-template-rows: minmax(0, 1fr); }
.folders, .detail { min-height: 0; overflow: auto; padding: 12px; }
/* The list's title stays; the entries under it scroll. */
.list { min-height: 0; display: flex; flex-direction: column; padding: 12px 12px 0; }
.entry-list { flex: 1; min-height: 0; overflow: auto; padding-bottom: 12px; }
.folders { border-right: 1px solid var(--border); }
.list { border-right: 1px solid var(--border); }
.nav-title { margin: 14px 8px 4px; color: var(--text-faint); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.folder { display: flex; justify-content: space-between; width: 100%; text-align: left; padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer; }
.folder:hover { background: var(--surface-2); }
.folder[aria-current="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.folder[data-depth="1"] { padding-left: 24px; } .folder[data-depth="2"] { padding-left: 38px; } .folder[data-depth="3"] { padding-left: 52px; }
.folder[data-depth="4"], .folder[data-depth="5"], .folder[data-depth="6"] { padding-left: 66px; }
.folder-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.count { color: var(--text-faint); }
.list-title { margin: 2px 4px 10px; font-size: 15px; }
.entry-list { list-style: none; margin: 0; padding: 0; }
.entry-row { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: transparent; cursor: pointer; }
.entry-row:hover { background: var(--surface-2); }
.entry-row[aria-current="true"] { background: var(--surface-3); }
.entry-name { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.entry-sub { display: block; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); }
.trash-row .entry-name, .trash-row .entry-sub { flex-basis: 100%; }
.trash-row .row-actions { margin-left: 0; margin-top: 4px; }
.trash-row .ask { flex-basis: 100%; }

/* Tools above the list: a new entry, the selected folder's actions, a folder's small form */
.list-tools:empty { display: none; }
.list-tools { margin: 0 4px 10px; }
.tool-row { display: flex; flex-wrap: wrap; gap: 6px; }
.folder-form { display: grid; gap: 8px; padding: 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.folder-form .actions { margin-top: 0; }
.form-title { font-weight: 600; }
.nav-title-row { display: flex; align-items: center; justify-content: space-between; }
.nav-title-row .btn { text-transform: none; letter-spacing: 0; }

/* Questions asked in the page */
.ask { margin: 8px 0 12px; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); border: 1px solid rgba(242, 196, 109, 0.3); }
.ask-message { margin: 0 0 8px; }
.ask .actions { margin-top: 0; flex-wrap: wrap; }

/* The opened entry's actions, and the editor */
.entry-actions { display: flex; gap: 8px; margin-bottom: 12px; }
.editor .field { margin-bottom: 14px; }
.field-label { margin-bottom: 4px; color: var(--text-muted); }
.field-line { display: flex; align-items: center; gap: 8px; }
.field-line > input, .field-line > select, .field-line > textarea { flex: 1; min-width: 0; }
.generator { margin: -8px 0 14px; flex-wrap: wrap; }
.generator select { width: auto; flex: 0 0 auto; padding: 3px 8px; font-size: 12.5px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); white-space: nowrap; }
.rows { display: grid; gap: 6px; margin-bottom: 6px; }
.rows:empty { display: none; }
.edit-row { display: flex; align-items: center; gap: 6px; }
.edit-row > input { flex: 1; min-width: 0; }
.editor .actions { position: sticky; bottom: -12px; padding: 10px 0 12px; background: var(--bg); border-top: 1px solid var(--border); }
.detail:focus { outline: none; }
.detail .back { display: none; margin-bottom: 8px; }
.entry-title { margin: 0 0 14px; font-size: 20px; word-break: break-word; }
.detail-row { display: grid; grid-template-columns: 170px 1fr; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.detail-label { color: var(--text-muted); word-break: break-word; }
.detail-value { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; word-break: break-all; }
.row-actions { display: inline-flex; gap: 6px; margin-left: auto; }
.code { font-size: 18px; letter-spacing: 0.08em; color: var(--accent-strong); }
.notes { white-space: pre-wrap; word-break: break-word; }
.plain { list-style: none; margin: 0; padding: 0; width: 100%; }
.plain li { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 2px 0; }

/* The account's settings, in the entry column */
.account-heading { margin: 22px 0 4px; font-size: 15px; }
.account .tool-row { margin: 8px 0; }
.account-panel:empty { display: none; }
.account-panel { margin-top: 14px; max-width: 520px; }
.account-form .field { margin-bottom: 10px; }
.hint { margin: 4px 0 0; }
.qr-box { width: 216px; padding: 0; margin: 6px 0 10px; background: #fff; border-radius: var(--radius-sm); }
.qr { display: block; width: 216px; height: 216px; }
.setup-key { font-size: 15px; letter-spacing: 0.04em; word-break: break-all; }
.codes { columns: 2; font-size: 15px; }
.codes li { padding: 3px 0; }
input[type="file"] { width: 100%; color: var(--text-muted); }
input[type="file"]::file-selector-button {
    margin-right: 10px; padding: 6px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--surface-2); color: var(--text); font: inherit; cursor: pointer;
}
.import-plan p, .import-report p { margin: 4px 0; }
.import-plan .warnings, .import-report .warnings { margin: 8px 0; padding: 8px 12px; border-radius: var(--radius-sm); background: var(--warn-soft); }
.warnings li { display: list-item; overflow-wrap: anywhere; }

/* Password health, in the entry column */
.health .tool-row { margin: 8px 0; }
.leak-status:empty { display: none; }
.health-tiles { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.health-tile {
    display: flex; flex-direction: column; align-items: flex-start; min-width: 108px; padding: 8px 12px; cursor: pointer;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface-2); text-align: left;
}
.health-tile[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.health-count { font-size: 20px; font-weight: 600; }
.health-label { font-size: 12.5px; color: var(--text-muted); }
.health-list li { display: block; padding: 0; }
.health-row {
    display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
    background: transparent; text-align: left; cursor: pointer;
}
.health-row:hover { background: var(--surface-2); }
.health-name { font-weight: 600; overflow-wrap: anywhere; }
.health-issues { color: var(--warn); }

/* The recovery kit exists only while it is printed (views/account.js adds it, then takes it away). */
.print-kit { display: none; }
@media print {
    html, body { height: auto; background: #fff; color: #000; font: 12pt/1.5 var(--font); }
    #app { display: none !important; }
    .print-kit { display: block; padding: 0 8mm; }
    .print-kit h1 { font-size: 20pt; margin: 0 0 12pt; }
    .print-kit h2 { font-size: 14pt; margin: 18pt 0 6pt; }
    .kit-label { font-weight: 600; }
    .kit-line { display: inline-block; width: 70mm; border-bottom: 1px solid #000; }
    .kit-code { font: 13pt var(--mono); margin: 2pt 0; }
}

@media (max-width: 900px) {
    .topbar { flex-wrap: wrap; }
    .topbar #search { order: 3; max-width: none; flex-basis: 100%; }
    .columns { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
    .columns:has(.entry, .account, .health) { grid-template-rows: minmax(0, 1fr); }
    .folders { border-right: 0; border-bottom: 1px solid var(--border); max-height: 30vh; }
    .list { border-right: 0; }
    .detail:not(:has(.entry, .account, .health)) { display: none; }
    .columns:has(.entry, .account, .health) .folders, .columns:has(.entry, .account, .health) .list { display: none; }
    .detail .back { display: inline-block; }
    .detail-row { grid-template-columns: 1fr; gap: 2px; }
    .custom-field { flex-wrap: wrap; }
    .custom-field > input { flex-basis: 100%; }
}
