/* ══════════════════════════════════════════════════════════════
   Helium Start — styles.css
   ══════════════════════════════════════════════════════════════ */

/* ── Design tokens ────────────────────────────────────────────── */
:root {
    --bg-1:         #0f172a;
    --bg-2:         #1e1b4b;
    --panel:        rgba(255, 255, 255, 0.08);
    --panel-strong: rgba(255, 255, 255, 0.14);
    --text:         #f8fafc;
    --muted:        #cbd5e1;
    --accent:       #60a5fa;
    --border:       rgba(255, 255, 255, 0.16);
    --shadow:       0 14px 40px rgba(0, 0, 0, 0.25);
    --radius:       12px;
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

/* ── Page ─────────────────────────────────────────────────────── */
body {
    font-family: "Segoe UI", Inter, system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    color: var(--text);
    background:
        radial-gradient(circle at 10% 10%,  rgba(96,  165, 250, 0.25), transparent 45%),
        radial-gradient(circle at 80% 20%,  rgba(139,  92, 246, 0.22), transparent 48%),
        linear-gradient(160deg, var(--bg-1), var(--bg-2));
    padding: 18px;
}

.page {
    max-width: 1700px;
    margin: 0 auto;
    display: grid;
    gap: 14px;
}

/* ════════════════════════════════════════════════════════════════
   TOPBAR
   ════════════════════════════════════════════════════════════════ */
.topbar {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.topbar-brand { flex: 1; min-width: 0; }
h1            { font-size: 1.4rem; font-weight: 700; }
.subtitle     { margin-top: 4px; color: var(--muted); font-size: 0.85rem; }

/* ── Clock ────────────────────────────────────────────────────── */
.clock {
    font-size: 0.82rem;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    white-space: nowrap;
    letter-spacing: 0.01em;
}

/* ── Actions row ──────────────────────────────────────────────── */
.topbar-actions {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
}

/* ── Search ───────────────────────────────────────────────────── */
.search-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.search-hint {
    position: absolute;
    right: 9px;
    font-family: inherit;
    font-size: 0.68rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 5px;
    color: var(--muted);
    pointer-events: none;
    transition: opacity 0.15s ease;
    line-height: 1.6;
}
.search-wrap:focus-within .search-hint { opacity: 0; }

/* ── Shared control base ──────────────────────────────────────── */
#searchInput,
#toggleAllBtn,
.icon-btn,
.edit-toolbar button {
    border-radius: 10px;
    border: 1px solid var(--border);
    background: rgba(2, 6, 23, 0.35);
    color: var(--text);
    font-size: 0.88rem;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease;
}

#searchInput {
    width: min(380px, 65vw);
    padding: 9px 36px 9px 12px;
}
#searchInput::placeholder { color: #94a3b8; }

/* Focus ring — keyboard-visible only */
#searchInput:focus-visible,
#toggleAllBtn:focus-visible,
.icon-btn:focus-visible,
.edit-toolbar button:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.25);
    outline: none;
}

#toggleAllBtn {
    padding: 9px 12px;
    cursor: pointer;
}
#toggleAllBtn:hover { background: rgba(2, 6, 23, 0.6); }

/* Icon-only button (notes toggle) */
.icon-btn {
    padding: 8px 11px;
    cursor: pointer;
    line-height: 1;
}
.icon-btn:hover,
.icon-btn.active {
    background: rgba(2, 6, 23, 0.6);
    border-color: var(--accent);
}

a.icon-btn { display: inline-flex; align-items: center; text-decoration: none; }

/* Edit toolbar */
.edit-toolbar { display: flex; gap: 5px; }
.edit-toolbar button {
    padding: 8px 11px;
    cursor: pointer;
}
.edit-toolbar button:hover { background: rgba(2, 6, 23, 0.6); }
.edit-toolbar button.active {
    background: rgba(96, 165, 250, 0.18);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Notes widget (full-width collapsible row) ────────────────── */
.notes-widget {
    flex-basis: 100%;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.28s ease;
}
.notes-widget.notes-open { max-height: 170px; }

#notesArea {
    display: block;
    width: 100%;
    height: 148px;
    margin-top: 10px;
    padding: 10px 12px;
    background: rgba(2, 6, 23, 0.45);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.87rem;
    resize: none;
    outline: none;
    transition: border-color 0.15s ease;
}
#notesArea::placeholder { color: #94a3b8; }
#notesArea:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

/* ════════════════════════════════════════════════════════════════
   QUICK BAR  (pinned favorites strip)
   ════════════════════════════════════════════════════════════════ */
.quick-bar {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 9px 12px;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.qb-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    transition: background 0.15s ease, transform 0.12s ease;
}
.qb-link:hover         { background: rgba(255,255,255,0.22); transform: translateY(-1px); }
.qb-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.qb-link i             { color: #93c5fd; font-size: 0.8rem; flex-shrink: 0; }

/* Most-used strip (usage-strip.js) */
.usage-bar[hidden] { display: none; }
.usage-label {
    color: var(--muted); font-size: 0.74rem; text-decoration: none; text-transform: uppercase;
    letter-spacing: 0.06em; padding-right: 6px; white-space: nowrap;
}
.usage-label:hover { color: var(--accent); }
.usage-fav { width: 14px; height: 14px; border-radius: 3px; flex-shrink: 0; }

/* ════════════════════════════════════════════════════════════════
   STATS
   ════════════════════════════════════════════════════════════════ */
.stats { color: var(--muted); font-size: 0.83rem; padding: 0 4px; }

/* ════════════════════════════════════════════════════════════════
   SILOS GRID
   ════════════════════════════════════════════════════════════════ */
.silos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 12px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to   { opacity: 1; transform: translateY(0); }
}

.silo {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.18s ease both;
}

/* Feature 7: color accent */
.silo.has-accent {
    border-left: 3px solid var(--silo-accent);
}
.silo.has-accent .silo-icon {
    color: var(--silo-accent);
}

/* ── Silo header ──────────────────────────────────────────────── */
.silo-header {
    display: flex;
    align-items: center;
}

.silo-collapse-btn {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--text);
    padding: 10px 6px 10px 12px;
    display: flex;
    align-items: center;
    gap: 9px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background 0.15s ease;
}
.silo-collapse-btn:hover         { background: rgba(255,255,255,0.06); }
.silo-collapse-btn:focus-visible {
    background: rgba(255,255,255,0.06);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

.silo-icon {
    color: #c4b5fd;
    font-size: 0.95rem;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.silo-title {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.silo-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 10px;
    flex-shrink: 0;
}

/* Feature 4: open-all button (appears on hover) */
.open-all-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    font-size: 0.72rem;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
    line-height: 1;
    font-family: inherit;
}
.silo-header:hover .open-all-btn     { opacity: 1; }
.open-all-btn:hover                   { background: rgba(255,255,255,0.1); color: var(--text); }
.open-all-btn:focus-visible           { opacity: 1; outline: 2px solid var(--accent); outline-offset: 2px; }

.silo-meta {
    font-size: 0.76rem;
    color: #93c5fd;
    white-space: nowrap;
}

/* ── Silo link list ───────────────────────────────────────────── */
.silo-links {
    display: grid;
    gap: 8px;
    padding: 0 10px 10px;
    max-height: 1100px;
    transition: max-height 0.3s ease, padding 0.2s ease;
}
.silo.collapsed .silo-links {
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
}

/* ════════════════════════════════════════════════════════════════
   LINK CARDS
   ════════════════════════════════════════════════════════════════ */
.link-card {
    text-decoration: none;
    color: var(--text);
    background: var(--panel-strong);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 10px;
    display: flex;
    align-items: flex-start;
    gap: 9px;
    min-width: 0;
    position: relative;
    transition: transform 0.15s ease, background 0.15s ease;
}
.link-card:hover         { background: rgba(255,255,255,0.22); transform: translateY(-1px); }
.link-card:focus-visible {
    background: rgba(255,255,255,0.22);
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    transform: translateY(-1px);
}

.favorite-link { border-color: rgba(250, 204, 21, 0.55); }
.favorite-link .link-title::after {
    content: "★";
    display: inline-block;
    margin-left: 6px;
    color: #facc15;
    font-size: 0.68rem;
    vertical-align: text-top;
}

.link-icon {
    width: 16px;
    text-align: center;
    color: #93c5fd;
    font-size: 0.85rem;
    flex-shrink: 0;
    margin-top: 2px;
}

.link-text-wrap {
    min-width: 0;
    display: grid;
    gap: 2px;
}

.link-title {
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.link-host {
    color: var(--muted);
    font-size: 0.72rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Feature 3: tag pills */
.link-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 3px;
}
.tag-pill {
    border: 1px solid rgba(96, 165, 250, 0.35);
    background: rgba(96, 165, 250, 0.1);
    color: var(--accent);
    border-radius: 999px;
    padding: 1px 7px;
    font-size: 0.67rem;
    cursor: pointer;
    font-family: inherit;
    line-height: 1.6;
    transition: background 0.15s ease;
}
.tag-pill:hover         { background: rgba(96, 165, 250, 0.25); }
.tag-pill:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* ── Feature 8: edit mode ─────────────────────────────────────── */
.edit-mode-card {
    pointer-events: none; /* disables navigation so only the edit button works */
}
.link-edit-btn {
    pointer-events: auto;
    position: absolute;
    top: 7px;
    right: 7px;
    border: none;
    background: rgba(96, 165, 250, 0.15);
    color: var(--accent);
    border-radius: 6px;
    padding: 4px 7px;
    font-size: 0.72rem;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
}
/* Always show in edit mode; also show on hover when not in edit mode */
.edit-mode-card .link-edit-btn,
.link-card:hover .link-edit-btn { opacity: 1; }
.link-edit-btn:hover             { background: rgba(96, 165, 250, 0.3); }

.add-link-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 8px 10px;
    background: rgba(96, 165, 250, 0.06);
    border: 1px dashed rgba(96, 165, 250, 0.35);
    border-radius: 10px;
    color: var(--accent);
    font-size: 0.82rem;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.15s ease;
}
.add-link-btn:hover         { background: rgba(96, 165, 250, 0.14); }
.add-link-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Empty search state ───────────────────────────────────────── */
.empty-message {
    grid-column: 1 / -1;
    background: var(--panel);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--muted);
    text-align: center;
    padding: 28px;
    font-size: 0.9rem;
}

/* ════════════════════════════════════════════════════════════════
   LINK EDITOR MODAL  (native <dialog>)
   ════════════════════════════════════════════════════════════════ */
.link-modal {
    background: #171d33;
    border: 1px solid var(--border);
    border-radius: 16px;
    color: var(--text);
    padding: 24px;
    width: min(480px, 92vw);
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.65);
    outline: none;
}
.link-modal::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.modal-heading { font-size: 1.05rem; font-weight: 700; margin-bottom: 18px; }

.modal-form { display: grid; gap: 12px; }

.modal-label {
    display: grid;
    gap: 5px;
    font-size: 0.82rem;
    color: var(--muted);
}
.modal-label input[type="text"],
.modal-label input[type="url"] {
    padding: 9px 12px;
    background: rgba(2, 6, 23, 0.5);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.88rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s ease;
}
.modal-label input:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}
.modal-label input[readonly] { opacity: 0.5; cursor: not-allowed; }

.modal-checkbox {
    flex-direction: row;
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--text);
    cursor: pointer;
}

.required { color: #f87171; font-style: normal; margin-left: 2px; }
.hint      { color: var(--muted); font-size: 0.74rem; margin-left: 4px; font-style: normal; }

.modal-actions {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 9px 18px;
    border-radius: 9px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: 0.87rem;
    font-family: inherit;
    font-weight: 500;
    transition: background 0.15s ease;
}
.btn-primary   { background: var(--accent); color: #0f172a; font-weight: 700; }
.btn-primary:hover   { background: #93c5fd; }
.btn-secondary { background: var(--panel-strong); border-color: var(--border); color: var(--text); }
.btn-secondary:hover { background: rgba(255,255,255,0.22); }
.btn-danger    { background: rgba(239,68,68,0.12); border-color: rgba(239,68,68,0.4); color: #f87171; margin-left: auto; }
.btn-danger:hover    { background: rgba(239,68,68,0.28); }

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 720px) {
    body   { padding: 10px; }
    .topbar { padding: 12px; }

    .search-hint { display: none; }
    #searchInput { width: 100%; padding: 9px 12px; }

    .clock { display: none; }

    .silos { grid-template-columns: 1fr; }
}
