/* =============================================================================
 * Life Organizer — Design system
 * Aesthetic: calm, editorial, trustworthy. Warm paper background, deep sage/teal
 * ink, a characterful serif display (Fraunces) over a quiet humanist sans.
 * ============================================================================= */

:root {
  --paper:        #f6f4ee;
  --paper-2:      #fffdf8;
  --ink:          #1f2d2b;
  --ink-soft:     #46514e;
  --sage:         #4ba89a;
  --sage-deep:    #2f6f64;
  --sage-tint:    #e4efec;
  --line:         #d9e1de;
  --danger:       #b3463c;
  --danger-tint:  #fbe9e6;
  --gold:         #c8a64e;
  --shadow:       0 1px 2px rgba(31,45,43,.05), 0 8px 30px rgba(31,45,43,.07);
  --radius:       14px;
  --maxw:         1180px;
  --sans:         "Public Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif:        "Fraunces", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 80% -10%, #eef4f2 0%, transparent 60%),
    var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
[hidden] { display: none !important; }

/* ---- typography -------------------------------------------------------- */
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; margin: 0; }
.kicker {
  font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.16em;
  font-size: 11px; font-weight: 700; color: var(--sage-deep); margin: 0 0 6px;
}

/* =============================================================================
 * Gatekeeping screens (license / setup / unlock)
 * ============================================================================= */
.screen {
  min-height: 100vh; display: grid; place-items: center; padding: 30px 20px;
}
.card {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); width: 100%; max-width: 480px; padding: 44px 40px;
  animation: rise .5s cubic-bezier(.2,.8,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.brand-mark {
  display: inline-flex; align-items: center; gap: 10px; margin-bottom: 26px;
}
.brand-mark .glyph {
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--sage), var(--sage-deep));
  display: grid; place-items: center; color: #fff; font-family: var(--serif);
  font-weight: 600; font-size: 19px; box-shadow: var(--shadow);
}
.brand-mark .word { font-family: var(--serif); font-size: 20px; font-weight: 600; }

.card h1 { font-size: 30px; line-height: 1.1; margin-bottom: 12px; }
.card p.lede { color: var(--ink-soft); font-size: 15px; line-height: 1.6; margin: 0 0 22px; }

.field-row { margin-bottom: 16px; }
.field-row label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
input, textarea, select {
  width: 100%; font-family: var(--sans); font-size: 15px; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 13px; transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--sage);
  box-shadow: 0 0 0 3px rgba(75,168,154,.18);
}
textarea { resize: vertical; line-height: 1.5; }

.btn {
  font-family: var(--sans); font-size: 15px; font-weight: 600; cursor: pointer;
  border: none; border-radius: 11px; padding: 13px 18px; width: 100%;
  background: linear-gradient(135deg, var(--sage), var(--sage-deep)); color: #fff;
  box-shadow: var(--shadow); transition: transform .12s, filter .15s;
}
.btn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-secondary {
  background: transparent; color: var(--sage-deep);
  border: 1px solid var(--line); box-shadow: none; margin-top: 10px;
}
.btn-secondary:hover { background: var(--sage-tint); filter: none; }

.warn { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 4px; }

.checkline { display: flex; gap: 10px; align-items: flex-start; margin: 14px 0 18px; font-size: 13px; color: var(--ink-soft); line-height: 1.5; }
.checkline input { width: auto; margin-top: 2px; }

.notice {
  background: var(--sage-tint); border-radius: 12px; padding: 14px 16px;
  font-size: 13px; line-height: 1.55; color: var(--sage-deep); margin: 18px 0;
}
.notice.danger { background: var(--danger-tint); color: var(--danger); }

.price-tag {
  display: flex; align-items: baseline; gap: 8px; margin: 4px 0 20px;
}
.price-tag .amt { font-family: var(--serif); font-size: 46px; font-weight: 600; }
.price-tag .per { color: var(--ink-soft); font-size: 14px; }
.feature-list { list-style: none; padding: 0; margin: 0 0 24px; }
.feature-list li {
  padding: 8px 0 8px 28px; position: relative; font-size: 14px; color: var(--ink-soft);
  border-bottom: 1px solid var(--line);
}
.feature-list li::before {
  content: "✓"; position: absolute; left: 0; top: 8px; color: var(--sage);
  font-weight: 800;
}

/* =============================================================================
 * Application shell
 * ============================================================================= */
.app-shell { display: grid; grid-template-columns: 300px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--paper-2); border-right: 1px solid var(--line);
  padding: 24px 18px; position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column;
}
.sidebar .brand-mark { padding: 0 6px; }

.progress-block { padding: 6px 8px 16px; }
.progress-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.progress-top .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--ink-soft); font-weight: 700; }
.progress-top #progressPct { font-family: var(--serif); font-size: 22px; font-weight: 600; color: var(--sage-deep); }
.progress-track { height: 8px; background: var(--sage-tint); border-radius: 99px; overflow: hidden; }
#progressBar { height: 100%; width: 0; background: linear-gradient(90deg, var(--sage), var(--sage-deep)); border-radius: 99px; transition: width .5s cubic-bezier(.2,.8,.2,1); }

#nav { margin-top: 8px; flex: 1; }
.nav-item {
  display: grid; grid-template-columns: 10px 26px 1fr; align-items: center; gap: 10px;
  width: 100%; text-align: left; background: none; border: none; cursor: pointer;
  padding: 9px 10px; border-radius: 10px; color: var(--ink-soft); font-family: var(--sans);
  font-size: 14px; transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--sage-tint); }
.nav-item.active { background: var(--sage-tint); color: var(--sage-deep); font-weight: 600; }
.nav-dot { width: 8px; height: 8px; border-radius: 99px; background: var(--sage); opacity: .18; }
.nav-num { font-variant-numeric: tabular-nums; font-size: 12px; color: var(--gold); font-weight: 700; }

.sidebar-tools { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 8px; display: grid; gap: 4px; }
.tool-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: none; border: 1px solid transparent; cursor: pointer; padding: 11px 12px; border-radius: 10px;
  color: var(--ink); font-family: var(--sans); font-size: 14.5px; font-weight: 500; transition: background .15s, border-color .15s;
}
.tool-btn .tool-ico {
  flex: none; width: 30px; height: 30px; border-radius: 8px; background: var(--sage-tint);
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px; line-height: 1;
}
.tool-btn:hover { background: var(--sage-tint); border-color: var(--line); color: var(--sage-deep); }
.tool-btn.on { background: var(--sage); color: #fff; }
.tool-btn.on .tool-ico { background: rgba(255,255,255,.25); }
.tool-btn.danger:hover { background: var(--danger-tint); color: var(--danger); }
.tool-btn.danger:hover .tool-ico { background: rgba(179,70,60,.18); }

/* ---- main content ------------------------------------------------------ */
.main { padding: 0; overflow-x: hidden; }
.topbar {
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(8px);
  background: rgba(246,244,238,.82); border-bottom: 1px solid var(--line);
  padding: 14px 36px; display: flex; justify-content: space-between; align-items: center;
}
#saveState { font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 7px; }
#saveState::before { content: ""; width: 8px; height: 8px; border-radius: 99px; background: var(--sage); }
#saveState[data-state="saving"]::before { background: var(--gold); animation: pulse 1s infinite; }
#saveState[data-state="error"]::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

.mobile-menu { display: none; }

#sectionView { max-width: 760px; margin: 0 auto; padding: 40px 36px 90px; }
.section-header { margin-bottom: 28px; }
.section-header h2 { font-size: 38px; line-height: 1.05; margin-bottom: 12px; }
.section-header .intro { color: var(--ink-soft); font-size: 15.5px; line-height: 1.65; max-width: 64ch; }
.sensitive-banner {
  margin-top: 14px; background: var(--danger-tint); color: var(--danger);
  font-size: 13px; padding: 10px 14px; border-radius: 10px;
}

.fields-block { display: grid; gap: 18px; margin-bottom: 30px; }
.field { display: block; }
.field-block { margin-bottom: 18px; }
.field-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }

.group {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px; margin-bottom: 24px; box-shadow: var(--shadow);
}
.group-head h3 { font-size: 21px; color: var(--sage-deep); margin-bottom: 14px; }
.record {
  border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin-bottom: 14px;
  background: var(--paper);
}
.record-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.record-title { font-weight: 700; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--sage-deep); }
.record-del { background: none; border: none; color: var(--danger); cursor: pointer; font-size: 13px; font-weight: 600; }
.record-del:hover { text-decoration: underline; }
.record-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.record-grid .field:has(textarea) { grid-column: 1 / -1; }
.empty-hint { color: var(--ink-soft); font-size: 14px; font-style: italic; margin: 0 0 14px; }
.btn-add {
  background: var(--sage-tint); border: 1px dashed var(--sage); color: var(--sage-deep);
  border-radius: 10px; padding: 11px 16px; cursor: pointer; font-family: var(--sans);
  font-size: 14px; font-weight: 600; transition: background .15s;
}
.btn-add:hover { background: #d8eae6; }

.sensitive-wrap { position: relative; }
.sensitive-wrap .reveal-one {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; cursor: pointer; font-size: 15px; opacity: .55;
}
.sensitive-wrap .reveal-one:hover { opacity: 1; }

.section-foot { display: flex; justify-content: space-between; gap: 12px; margin-top: 36px; padding-top: 22px; border-top: 1px solid var(--line); }
.btn-ghost {
  background: var(--paper-2); border: 1px solid var(--line); color: var(--sage-deep);
  border-radius: 10px; padding: 11px 16px; cursor: pointer; font-family: var(--sans);
  font-size: 14px; font-weight: 600; max-width: 48%; transition: background .15s;
}
.btn-ghost:hover:not([disabled]) { background: var(--sage-tint); }
.btn-ghost[disabled] { opacity: 0; cursor: default; }

/* ---- toast ------------------------------------------------------------- */
#toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--paper-2); padding: 13px 20px; border-radius: 12px;
  font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 50; max-width: 90vw;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* =============================================================================
 * Responsive
 * ============================================================================= */
@media (max-width: 880px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 280px; z-index: 40;
    transform: translateX(-100%); transition: transform .25s; height: 100vh;
  }
  .sidebar.open { transform: none; }
  .mobile-menu { display: inline-flex; }
  .topbar { padding: 12px 18px; }
  #sectionView { padding: 28px 18px 80px; }
  .section-header h2 { font-size: 30px; }
  .record-grid { grid-template-columns: 1fr; }
  .scrim { position: fixed; inset: 0; background: rgba(31,45,43,.4); z-index: 39; }
  .scrim[hidden] { display: none; }
  .menu-btn {
    background: var(--paper-2); border: 1px solid var(--line); border-radius: 9px;
    padding: 8px 12px; font-size: 14px; cursor: pointer; font-weight: 600; color: var(--ink);
  }
}
@media (min-width: 881px) { .scrim { display: none; } }

/* =============================================================================
 * Attachments + Documents library
 * ============================================================================= */
.attach-zone {
  margin: 14px 0 4px; padding: 14px 16px; background: var(--sage-tint);
  border: 1px solid var(--line); border-radius: 12px;
}
.record .attach-zone { margin-top: 14px; background: var(--paper-2); }
.attach-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; flex-wrap: wrap; }
.attach-label { font-size: 13px; font-weight: 700; color: var(--sage-deep); }
.attach-add {
  display: inline-flex; align-items: center; cursor: pointer;
  background: var(--paper-2); border: 1px dashed var(--sage); color: var(--sage-deep);
  border-radius: 9px; padding: 7px 13px; font-size: 13px; font-weight: 600; transition: background .15s;
}
.attach-add:hover { background: #d8eae6; }
.attach-empty { font-size: 13px; color: var(--ink-soft); font-style: italic; line-height: 1.5; }

.file-chips { display: flex; flex-wrap: wrap; gap: 9px; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px; background: var(--paper-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 8px 6px 11px; max-width: 100%;
}
.file-ico { font-size: 16px; line-height: 1; }
.file-open {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  background: none; border: none; cursor: pointer; text-align: left; padding: 0; min-width: 0;
}
.file-name { font-size: 13px; font-weight: 600; color: var(--ink); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name:hover { color: var(--sage-deep); text-decoration: underline; }
.file-meta { font-size: 11px; color: var(--ink-soft); }
.file-del {
  background: none; border: none; cursor: pointer; color: var(--ink-soft);
  font-size: 14px; line-height: 1; padding: 4px; border-radius: 6px; transition: background .15s, color .15s;
}
.file-del:hover { background: var(--danger-tint); color: var(--danger); }

.lib-grid { display: grid; gap: 12px; }
.lib-card {
  display: grid; grid-template-columns: 44px 1fr auto; align-items: center; gap: 14px;
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; box-shadow: var(--shadow);
}
.lib-ico { font-size: 26px; text-align: center; }
.lib-name { font-size: 15px; font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-meta { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }
.lib-open {
  background: var(--sage-tint); border: 1px solid var(--line); color: var(--sage-deep);
  border-radius: 9px; padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s;
}
.lib-open:hover { background: #d8eae6; }

@media (max-width: 880px) {
  .file-name { max-width: 150px; }
  .lib-card { grid-template-columns: 36px 1fr auto; gap: 10px; padding: 12px; }
}

/* =============================================================================
 * Info buttons + tips modal (centered on desktop, bottom sheet on mobile)
 * ============================================================================= */
.section-title { display: inline-flex; align-items: center; gap: 14px; flex-wrap: wrap; }

/* section-level "Tips" pill — clearly tappable */
.info-pill {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 13px 6px 10px; border-radius: 999px; cursor: pointer;
  border: 1.5px solid var(--sage); background: var(--sage-tint); color: var(--sage-deep);
  font-family: var(--sans); font-size: 13px; font-weight: 700; letter-spacing: .01em;
  transition: background .15s, transform .12s; vertical-align: middle;
}
.info-pill:hover { background: var(--sage); color: #fff; transform: translateY(-1px); }
.info-pill-ico { font-size: 14px; line-height: 1; }

.info-btn {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid var(--sage); background: var(--paper-2); color: var(--sage-deep);
  font-family: var(--serif); font-style: italic; font-weight: 600; font-size: 14px;
  line-height: 1; cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, transform .12s; vertical-align: middle;
}
.info-btn:hover { background: var(--sage); color: #fff; transform: translateY(-1px); }
.info-btn-field {
  width: 20px; height: 20px; font-size: 12px; border-width: 1.5px;
  border-color: var(--sage); color: var(--sage-deep); margin-left: 4px;
}
.info-btn-field:hover { background: var(--sage); color: #fff; transform: none; }

body.modal-open { overflow: hidden; }

.info-modal {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; padding: 24px;
  background: rgba(31,45,43,.5); backdrop-filter: blur(3px);
}
.info-modal.open { display: flex; animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.info-modal-card {
  background: var(--paper-2); border-radius: 18px; box-shadow: 0 20px 60px rgba(31,45,43,.3);
  width: 100%; max-width: 520px; max-height: 80vh; display: flex; flex-direction: column;
  overflow: hidden; animation: popIn .25s cubic-bezier(.2,.8,.2,1);
}
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }

.info-modal-head {
  display: flex; align-items: center; gap: 12px; padding: 20px 22px 14px;
  border-bottom: 1px solid var(--line);
}
.info-modal-icon { font-size: 22px; line-height: 1; }
.info-modal-title { font-family: var(--serif); font-size: 21px; flex: 1; color: var(--ink); margin: 0; }
.info-modal-close {
  flex: none; width: 32px; height: 32px; border-radius: 9px; border: none; cursor: pointer;
  background: var(--sage-tint); color: var(--sage-deep); font-size: 14px; transition: background .15s;
}
.info-modal-close:hover { background: #d8eae6; }

.info-modal-body { padding: 18px 22px 24px; overflow-y: auto; }
.info-modal-body p { margin: 0 0 14px; font-size: 15px; line-height: 1.65; color: var(--ink-soft); }
.info-modal-body p:last-child { margin-bottom: 0; }

/* mobile: dock to bottom as a sheet */
@media (max-width: 880px) {
  .info-modal { align-items: flex-end; padding: 0; }
  .info-modal-card {
    max-width: 100%; max-height: 88vh; border-radius: 20px 20px 0 0;
    animation: sheetUp .28s cubic-bezier(.2,.8,.2,1);
  }
  @keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
  .info-modal-head { padding-top: 22px; }
  .info-modal-head::before {
    content: ""; position: absolute; top: 9px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: 99px; background: var(--line);
  }
  .info-modal-head { position: relative; }
}

/* =============================================================================
 * Guide section
 * ============================================================================= */
.guide-blocks { display: grid; gap: 22px; }
.guide-block {
  background: var(--paper-2); border: 1px solid var(--line); border-radius: 14px;
  padding: 22px 24px; box-shadow: var(--shadow);
}
.guide-block h3 { font-size: 20px; color: var(--sage-deep); margin-bottom: 12px; }
.guide-block p { font-size: 15px; line-height: 1.7; color: var(--ink-soft); margin: 0 0 12px; }
.guide-block p:last-child { margin-bottom: 0; }

/* =============================================================================
 * Passphrase reveal toggle (setup + unlock screens)
 * ============================================================================= */
.pass-wrap { position: relative; }
.pass-wrap input { padding-right: 46px; }
.pass-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 8px; border: none; cursor: pointer;
  background: transparent; font-size: 17px; line-height: 1; opacity: .55;
  display: inline-flex; align-items: center; justify-content: center;
  transition: opacity .15s, background .15s;
}
.pass-toggle:hover { opacity: 1; background: var(--sage-tint); }
.pass-toggle.on { opacity: 1; background: var(--sage-tint); }

/* =============================================================================
 * Backup reminder banner + primary backup button
 * ============================================================================= */
.tool-btn-primary {
  background: var(--sage); color: #fff; font-weight: 700;
}
.tool-btn-primary .tool-ico { background: rgba(255,255,255,.22); }
.tool-btn-primary:hover { background: var(--sage-deep); color: #fff; border-color: transparent; }
.tool-btn-primary:hover .tool-ico { background: rgba(255,255,255,.28); }

.backup-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 0; padding: 13px 18px;
  background: linear-gradient(135deg, #fff6e2, #fdeccb);
  border-bottom: 1px solid #ecd9a8; color: #6b531a;
}
.backup-banner .banner-ico { font-size: 20px; line-height: 1; }
.backup-banner .banner-text { flex: 1; min-width: 220px; font-size: 13.5px; line-height: 1.5; }
.backup-banner .banner-btn {
  flex: none; background: var(--sage-deep); color: #fff; border: none; cursor: pointer;
  border-radius: 9px; padding: 9px 16px; font-family: var(--sans); font-size: 13.5px; font-weight: 700;
  transition: filter .15s, transform .12s;
}
.backup-banner .banner-btn:hover { filter: brightness(1.08); transform: translateY(-1px); }
.backup-banner .banner-dismiss {
  flex: none; background: transparent; border: none; cursor: pointer; font-size: 15px;
  color: #6b531a; opacity: .6; padding: 4px 6px; border-radius: 6px;
}
.backup-banner .banner-dismiss:hover { opacity: 1; background: rgba(107,83,26,.1); }

@media (max-width: 880px) {
  .backup-banner { padding: 12px 16px; }
  .backup-banner .banner-text { min-width: 100%; order: 3; }
}