/* ============================================================
   FamLi Client — Dark & Premium
   Palette: deep anthracite, mint accent, lavender = private
   Type: Bricolage Grotesque (display) · Schibsted Grotesk (UI) · JetBrains Mono (numbers)
   ============================================================ */

:root {
   --bg: #0e1113;
   --panel: #181c1f;
   --surface: #21272b;
   --surface-hover: #2a3137;
   --field: #1f2428;
   --ink: #ece9e1;
   --muted: #8b938f;
   --muted2: #7e8682;
   --line: #2c3338;
   --line2: #2c3236;
   --track: #2f363b;
   --accent: #5fe3a1;
   --accent-ink: #0e1113;
   --danger: #ff6f61;
   --private: #b79cff;
   --private-tint: rgba(183, 156, 255, .13);
   --private-border: #34303f;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
   background: var(--bg);
   font-family: 'Schibsted Grotesk', system-ui, sans-serif;
   color: var(--ink);
   -webkit-font-smoothing: antialiased;
}

.container {
   max-width: 680px;
   margin: 24px auto;
   padding: 26px 20px 90px;
   width: 100%;
   background: var(--panel);
   border: 1px solid var(--line);
   border-radius: 20px;
   box-shadow: 0 10px 40px rgba(0, 0, 0, .35);
}

.hidden { display: none !important; }

/* ---------- Headers ---------- */
.section-label {
   font-family: 'Bricolage Grotesque', sans-serif;
   font-weight: 600;
   font-size: 20px;
   color: var(--ink);
   letter-spacing: -.3px;
   margin: 0 0 20px;
}

/* ---------- Inputs & primary buttons ---------- */
.add-row { display: flex; gap: 10px; align-items: center; }
.add-row.top { margin: 0 0 22px; }
.add-row.bottom { margin: 22px 0 0; }

.btn-toggle {
   flex: none;
   width: 48px;
   height: 48px;
   border: 1px solid var(--line2);
   border-radius: 12px;
   background: var(--field);
   color: var(--muted);
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 0;
   transition: all .15s ease;
}
.btn-toggle:hover { border-color: var(--private); color: var(--private); }
.btn-toggle.active {
   background: var(--private);
   border-color: var(--private);
   color: #1a1322;
}

.input {
   flex: 1;
   min-width: 0;
   height: 48px;
   padding: 0 16px;
   border: 1px solid var(--line2);
   border-radius: 12px;
   background: var(--field);
   font-family: 'Schibsted Grotesk', sans-serif;
   font-size: 15px;
   color: var(--ink);
   outline: none;
   transition: border-color .15s ease;
}
.input::placeholder { color: #6b736f; }
.input:focus { border-color: var(--accent); }

.btn-primary {
   flex: none;
   width: 48px;
   height: 48px;
   border: none;
   border-radius: 12px;
   background: var(--accent);
   color: var(--accent-ink);
   font-size: 24px;
   line-height: 1;
   cursor: pointer;
   transition: filter .15s ease;
}
.btn-primary:hover { filter: brightness(1.08); }

/* ---------- List cards (landing) ---------- */
.lists { display: flex; flex-direction: column; gap: 10px; }

.list-card {
   --ring-accent: var(--accent);
   position: relative;
   background: var(--surface);
   border: 1px solid var(--line);
   border-radius: 14px;
   padding: 15px 18px;
   cursor: pointer;
   box-shadow: 0 4px 16px rgba(0, 0, 0, .28);
   transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.list-card:hover {
   transform: translateY(-2px);
   box-shadow: 0 10px 26px rgba(0, 0, 0, .4);
   border-color: #38424a;
}
.list-card-top {
   display: flex;
   justify-content: space-between;
   align-items: center;
   gap: 16px;
}
.list-name {
   font-family: 'Bricolage Grotesque', sans-serif;
   font-weight: 600;
   font-size: 16px;
   color: var(--ink);
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
}
.list-meta {
   font-family: 'JetBrains Mono', monospace;
   font-size: 11px;
   color: var(--muted2);
   margin-top: 3px;
}
.list-right { display: flex; align-items: center; gap: 6px; flex: none; }

/* Progress ring */
.list-ring {
   position: relative;
   width: 46px;
   height: 46px;
   flex: none;
   margin-left: 4px;
}
.ring-bg {
   width: 46px;
   height: 46px;
   border-radius: 50%;
   transition: background .4s ease;
}
.ring-inner {
   position: absolute;
   inset: 5px;
   border-radius: 50%;
   background: var(--surface);
   display: flex;
   align-items: center;
   justify-content: center;
   font-family: 'JetBrains Mono', monospace;
   font-size: 10.5px;
   font-weight: 700;
   color: var(--ring-accent);
}

/* ---------- Icon buttons ---------- */
.icon-btn {
   width: 30px;
   height: 30px;
   border: none;
   border-radius: 8px;
   background: transparent;
   color: var(--muted2);
   font-size: 17px;
   line-height: 1;
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 0;
   transition: all .15s ease;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--ink); }
.icon-btn.danger:hover { background: rgba(255, 111, 97, .14); color: var(--danger); }

/* Lock + delete on cards stay quiet until hover (desktop only) */
@media (hover: hover) {
    .list-right .icon-btn { opacity: 0; }
    .list-card:hover .list-right .icon-btn,
    .list-right .icon-btn.lock.active { opacity: 1; }
}
.icon-btn.lock { color: var(--muted2); }
.icon-btn.lock.active { color: var(--private); }
.icon-btn.lock:hover { color: var(--private); background: var(--private-tint); }

/* ---------- Detail view ---------- */
.back-btn {
   flex: none;
   width: 38px;
   height: 38px;
   border: 1px solid var(--line2);
   border-radius: 10px;
   background: var(--field);
   color: var(--muted);
   font-size: 22px;
   line-height: 1;
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 0 0 3px;
   transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.back-btn:hover { background: var(--surface-hover); color: var(--ink); border-color: #3a444c; }

.list-title {
   font-family: 'Bricolage Grotesque', sans-serif;
   margin: 0;
   font-size: 21px;
   font-weight: 700;
   letter-spacing: -.5px;
   flex: 0 1 auto;
   min-width: 0;
   overflow: hidden;
   text-overflow: ellipsis;
   white-space: nowrap;
}

.detail-head {
   display: flex;
   align-items: center;
   gap: 12px;
   margin: 0 0 14px;
}
.progress-pct {
   font-family: 'JetBrains Mono', monospace;
   font-size: 22px;
   font-weight: 700;
   color: var(--accent);
   margin-left: auto;
   flex: none;
}
.progress-bar-wrap { flex: 1; }
.progress-bar {
   height: 8px;
   border-radius: 99px;
   background: var(--track);
   overflow: hidden;
}
.progress-bar > span {
   display: block;
   height: 100%;
   background: var(--accent);
   transition: width .4s ease;
}
.progress-status {
   font-family: 'JetBrains Mono', monospace;
   font-size: 12px;
   color: var(--muted2);
   margin: 9px 0 22px;
}

/* ---------- Entry rows ---------- */
.entries { display: flex; flex-direction: column; }

.entry {
   display: flex;
   align-items: flex-start;
   gap: 13px;
   padding: 11px 4px;
   border-bottom: 1px solid var(--line);
}
.check {
   flex: none;
   width: 24px;
   height: 24px;
   margin-top: 1px;
   border-radius: 50%;
   border: 2px solid #4a534f;
   background: transparent;
   color: var(--accent-ink);
   font-size: 13px;
   line-height: 1;
   display: flex;
   align-items: center;
   justify-content: center;
   cursor: pointer;
   padding: 0;
   transition: all .15s ease;
}
.check.done {
   border-color: var(--accent);
   background: var(--accent);
   animation: pop .2s ease;
}
.entry-body { flex: 1; min-width: 0; }
.entry-title { font-size: 15px; font-weight: 500; color: var(--ink); }
.entry-desc { font-size: 12.5px; color: var(--muted2); margin-top: 2px; }
.entry.done .entry-title { color: var(--muted2); text-decoration: line-through; }
.entry.done .entry-desc { text-decoration: line-through; }

.entry-controls { display: flex; gap: 4px; flex: none; }
.icon-btn.edit { width: 30px; height: 30px; font-size: 14px; }
.icon-btn.del { width: 30px; height: 30px; font-size: 18px; }
.entry .icon-btn { opacity: .55; }
.entry:hover .icon-btn { opacity: 1; }

/* ---------- Inline edit ---------- */
.edit-fields {
   flex: 1;
   display: flex;
   flex-direction: column;
   gap: 8px;
}
.edit-input {
   height: 40px;
   padding: 0 12px;
   border: 1px solid var(--line2);
   border-radius: 9px;
   background: var(--field);
   font-family: 'Schibsted Grotesk', sans-serif;
   font-size: 15px;
   color: var(--ink);
   outline: none;
}
.edit-input.desc { height: 38px; font-size: 13.5px; }
.edit-input:focus { border-color: var(--accent); }
.edit-actions { display: flex; gap: 8px; margin-top: 2px; }
.btn-save {
   height: 34px;
   padding: 0 16px;
   border: none;
   border-radius: 8px;
   background: var(--accent);
   color: var(--accent-ink);
   font-family: 'Schibsted Grotesk', sans-serif;
   font-size: 13px;
   font-weight: 600;
   cursor: pointer;
}
.btn-cancel {
   height: 34px;
   padding: 0 14px;
   border: 1px solid var(--line2);
   border-radius: 8px;
   background: transparent;
   color: var(--muted);
   font-family: 'Schibsted Grotesk', sans-serif;
   font-size: 13px;
   cursor: pointer;
}

/* ---------- Add-entry row ---------- */
.add-row.entry-add {
   flex-wrap: wrap;
   margin-top: 24px;
   padding-top: 22px;
   border-top: 1px solid var(--line);
}
.add-row.entry-add .input.name { flex: 2 1 200px; }
.add-row.entry-add .input.desc { flex: 1 1 150px; height: 48px; font-size: 14px; }

/* ---------- Empty states ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted2); }
.empty-title { font-family: 'Bricolage Grotesque', sans-serif; font-size: 17px; color: var(--muted); }
.empty-sub { font-size: 14px; margin-top: 6px; }

/* ---------- Demo banner ---------- */
.demo-banner {
   position: fixed;
   left: 50%;
   bottom: 16px;
   transform: translateX(-50%);
   background: var(--surface);
   border: 1px solid var(--line);
   color: var(--muted);
   font-family: 'JetBrains Mono', monospace;
   font-size: 12px;
   letter-spacing: .3px;
   padding: 9px 16px;
   border-radius: 999px;
   box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
   z-index: 50;
}

@keyframes pop {
   0% { transform: scale(.5); }
   60% { transform: scale(1.18); }
   100% { transform: scale(1); }
}

/* ---------- App header (landing) ---------- */
.app-header {
   display: flex;
   align-items: center;
   justify-content: space-between;
   gap: 12px;
   background: transparent;
   padding: 2px 2px 0;
   margin-bottom: 18px;
}
.brand {
   font-family: 'Bricolage Grotesque', sans-serif;
   font-weight: 700;
   font-size: 24px;
   letter-spacing: -.4px;
   color: var(--ink);
}
.menu-wrap { position: relative; }
.menu-btn {
   width: 38px;
   height: 38px;
   border: 1px solid var(--line2);
   border-radius: 10px;
   background: var(--field);
   color: var(--muted);
   font-size: 18px;
   line-height: 1;
   cursor: pointer;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 0;
   transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.menu-btn:hover { background: var(--surface-hover); color: var(--ink); border-color: #3a444c; }
.menu-popup {
   position: absolute;
   top: 44px;
   right: 0;
   min-width: 192px;
   background: var(--surface);
   border: 1px solid var(--line);
   border-radius: 12px;
   box-shadow: 0 16px 40px rgba(0, 0, 0, .5);
   padding: 6px;
   z-index: 60;
   display: flex;
   flex-direction: column;
}
.menu-item {
   text-align: left;
   border: none;
   background: transparent;
   color: var(--ink);
   font-family: 'Schibsted Grotesk', sans-serif;
   font-size: 14px;
   padding: 10px 12px;
   border-radius: 8px;
   cursor: pointer;
   transition: background .12s ease;
}
.menu-item:hover { background: var(--surface-hover); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: rgba(255, 111, 97, .14); }
.menu-sep { height: 1px; background: var(--line); margin: 5px 8px; }

/* ---------- Private list option ---------- */
.private-check {
   display: flex;
   align-items: center;
   gap: 9px;
   margin: 0 0 22px 2px;
   font-size: 13.5px;
   color: var(--muted);
   cursor: pointer;
   user-select: none;
}
.private-check input {
   width: 16px;
   height: 16px;
   accent-color: var(--private);
   cursor: pointer;
   margin: 0;
}

.list-name-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.badge-private {
   display: inline-flex;
   align-items: center;
   gap: 4px;
   font-family: 'JetBrains Mono', monospace;
   font-size: 9px;
   letter-spacing: .6px;
   text-transform: uppercase;
   color: var(--private);
   background: var(--private-tint);
   padding: 3px 8px;
   border-radius: 999px;
   flex: none;
}
.lock-ico { display: block; }

/* Private list card treatment */
.list-card.private {
   --ring-accent: var(--private);
   border-color: var(--private-border);
}
.list-card.private .icon-btn.lock { color: var(--private); }
.list-card.private .icon-btn.lock:hover { background: var(--private-tint); color: var(--private); }

/* Detail view: private treatment */
.list-title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
#view-list.is-private .progress-bar > span { background: var(--private); }
#view-list.is-private .progress-pct { color: var(--private); }
#view-list.is-private .check.done { border-color: var(--private); background: var(--private); }
#view-list.is-private .edit-input:focus,
#view-list.is-private .input:focus { border-color: var(--private); }

/* ---------- Auth ---------- */
.auth-wrap {
   min-height: 100vh;
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 24px 20px;
   background: var(--bg);
}

.auth-box {
   background: var(--panel);
   border: 1px solid var(--line);
   border-radius: 20px;
   padding: 40px 36px;
   width: 100%;
   max-width: 400px;
   box-shadow: 0 16px 50px rgba(0, 0, 0, .45);
}

.auth-brand {
   font-family: 'Bricolage Grotesque', sans-serif;
   font-weight: 700;
   font-size: 30px;
   color: var(--ink);
   text-align: center;
   margin-bottom: 28px;
   letter-spacing: -.5px;
}

.auth-tabs {
   display: flex;
   gap: 4px;
   background: var(--field);
   border: 1px solid var(--line2);
   border-radius: 11px;
   padding: 4px;
   margin-bottom: 24px;
}

.auth-tab {
   flex: 1;
   border: none;
   background: transparent;
   padding: 9px;
   border-radius: 7px;
   font-family: 'Schibsted Grotesk', sans-serif;
   font-size: 14px;
   font-weight: 500;
   color: var(--muted);
   cursor: pointer;
   transition: background .15s, color .15s;
}

.auth-tab.active {
   background: var(--surface);
   color: var(--ink);
   box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}

.auth-form {
   display: flex;
   flex-direction: column;
   gap: 12px;
}

.auth-error {
   font-size: 13px;
   color: var(--danger);
   padding: 8px 12px;
   background: rgba(255, 111, 97, .12);
   border-radius: 8px;
   border: 1px solid rgba(255, 111, 97, .3);
}

.auth-success {
   font-size: 13px;
   color: #4caf7d;
   padding: 8px 12px;
   background: rgba(76, 175, 125, .12);
   border-radius: 8px;
   border: 1px solid rgba(76, 175, 125, .3);
}

.auth-link {
   background: none;
   border: none;
   color: var(--muted);
   font-size: 13px;
   cursor: pointer;
   padding: 4px 0;
   text-decoration: underline;
   text-underline-offset: 3px;
}

.auth-link:hover { color: var(--text); }

.auth-hint {
   font-size: 13px;
   color: var(--muted);
   margin: 0;
}

.btn-primary.full { width: 100%; margin-top: 4px; }

/* ---------- Modals ---------- */
.modal-overlay {
   position: fixed;
   inset: 0;
   background: rgba(0,0,0,.6);
   display: flex;
   align-items: center;
   justify-content: center;
   padding: 20px;
   z-index: 100;
}

.modal-box {
   background: var(--panel);
   border: 1px solid var(--line);
   border-radius: 20px;
   padding: 28px;
   width: 100%;
   max-width: 420px;
   box-shadow: 0 16px 50px rgba(0,0,0,.5);
   max-height: 90vh;
   overflow-y: auto;
}

.modal-head {
   display: flex;
   align-items: center;
   justify-content: space-between;
   margin-bottom: 24px;
}

.modal-title {
   font-family: 'Bricolage Grotesque', sans-serif;
   font-weight: 600;
   font-size: 18px;
   color: var(--ink);
}

.modal-close {
   background: none;
   border: none;
   color: var(--muted);
   font-size: 16px;
   cursor: pointer;
   padding: 4px 8px;
   border-radius: 8px;
   transition: background .15s;
}
.modal-close:hover { background: var(--surface-hover); color: var(--ink); }

.modal-form {
   display: flex;
   flex-direction: column;
   gap: 10px;
}

.modal-label {
   font-size: 12px;
   font-weight: 600;
   color: var(--muted);
   text-transform: uppercase;
   letter-spacing: .5px;
   margin-top: 4px;
}

.modal-optional { font-weight: 400; text-transform: none; letter-spacing: 0; }

.modal-sep {
   height: 1px;
   background: var(--line);
   margin: 20px 0;
}

.btn-secondary {
   height: 46px;
   border: 1px solid var(--line2);
   border-radius: 12px;
   background: var(--surface);
   color: var(--ink);
   font-family: 'Schibsted Grotesk', sans-serif;
   font-size: 15px;
   font-weight: 500;
   cursor: pointer;
   transition: background .15s;
}
.btn-secondary:hover { background: var(--surface-hover); }
.btn-secondary.full { width: 100%; }

.btn-danger-outline {
   height: 46px;
   border: 1px solid rgba(255,111,97,.4);
   border-radius: 12px;
   background: transparent;
   color: var(--danger);
   font-family: 'Schibsted Grotesk', sans-serif;
   font-size: 15px;
   font-weight: 500;
   cursor: pointer;
   transition: background .15s, border-color .15s;
}
.btn-danger-outline:hover { background: rgba(255,111,97,.1); border-color: var(--danger); }
.btn-danger-outline.full { width: 100%; }

/* Family modal content */
.family-name {
   font-family: 'Bricolage Grotesque', sans-serif;
   font-size: 20px;
   font-weight: 600;
   color: var(--ink);
   margin-bottom: 16px;
}

.member-row {
   display: flex;
   align-items: center;
   justify-content: space-between;
   padding: 10px 0;
   border-bottom: 1px solid var(--line);
}
.member-row:last-child { border-bottom: none; }
.member-name { color: var(--ink); font-size: 15px; }

.badge-admin {
   display: inline-block;
   font-size: 10px;
   font-weight: 600;
   text-transform: uppercase;
   letter-spacing: .5px;
   color: var(--accent-ink);
   background: var(--accent);
   padding: 2px 7px;
   border-radius: 999px;
   margin-left: 8px;
   vertical-align: middle;
}

.invite-code {
   margin-top: 10px;
   padding: 12px 16px;
   background: var(--surface);
   border: 1px solid var(--line2);
   border-radius: 10px;
   font-family: 'JetBrains Mono', monospace;
   font-size: 18px;
   font-weight: 700;
   color: var(--accent);
   text-align: center;
   letter-spacing: 2px;
}

/* List name double-click hint */
.list-name { cursor: pointer; }
.list-name:hover { color: var(--accent); }

/* ---------- Toast ---------- */
.toast {
   position: fixed;
   left: 50%;
   bottom: 64px;
   transform: translateX(-50%);
   background: var(--surface);
   border: 1px solid var(--line);
   color: var(--ink);
   font-family: 'JetBrains Mono', monospace;
   font-size: 12px;
   letter-spacing: .3px;
   padding: 9px 16px;
   border-radius: 999px;
   box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
   z-index: 70;
}
