/* ===== Fontes (self-hosted, PWA offline) ===== */
@font-face {
  font-family: 'Cormorant Garamond';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/cormorant-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Dancing Script';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/dancing-600.woff2') format('woff2');
}

:root {
  --bg: #f3ece0;
  --bg-2: #ece1cf;
  --paper: #fbf7ef;
  --card: #fdfbf6;
  --white: #ffffff;
  --ink: #4a3f35;
  --ink-soft: #8a7d6d;
  --ink-faint: #a99c8a;
  --terra: #b0714a;
  --terra-dark: #935b39;
  --terra-soft: #d7b295;
  --gold: #c39a5c;
  --green: #7d8a63;
  --line: #e7dcc8;
  --line-soft: #efe6d6;
  --danger: #b1503f;
  --ok: #6f8560;
  --shadow: 0 14px 40px rgba(120, 90, 55, 0.12);
  --shadow-sm: 0 6px 18px rgba(120, 90, 55, 0.08);
  --radius: 20px;
  --radius-sm: 14px;
  --display: 'Cormorant Garamond', Georgia, 'Times New Roman', serif;
  --script: 'Dancing Script', 'Segoe Script', cursive;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --sidebar: 248px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
  font-size: 15px;
}
h1, h2, h3 { margin: 0; font-weight: 600; }
.display { font-family: var(--display); font-weight: 600; letter-spacing: .3px; line-height: 1.08; }
.script { font-family: var(--script); }
a { color: var(--terra-dark); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

.app-root { min-height: 100dvh; }

/* ===== Boot ===== */
.boot { min-height: 100dvh; display: grid; place-items: center; text-align: center; color: var(--ink-soft); }
.brand-mark { font-family: var(--display); font-size: 54px; color: var(--terra); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 22px; border: none; border-radius: 12px; background: var(--terra);
  color: #fff; font-size: 15px; font-weight: 600; transition: background .15s, transform .1s;
}
.btn:hover { background: var(--terra-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: var(--terra-dark); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--bg-2); }
.btn.sm { padding: 9px 15px; font-size: 13.5px; border-radius: 10px; }
.btn.danger { background: var(--danger); }
.linkbtn { background: none; border: none; color: var(--terra-dark); font-weight: 600; font-size: 14px; padding: 0; }
.linkbtn:hover { text-decoration: underline; }

/* ===== Fields ===== */
.field { margin-bottom: 15px; }
.field > label { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field textarea, .field select {
  width: 100%; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--white); color: var(--ink); font-size: 15px; outline: none; font-family: inherit;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  border-color: var(--terra-soft); box-shadow: 0 0 0 3px rgba(176,113,74,.12);
}
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-wrap .eye { position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--ink-faint); padding: 6px; line-height: 0; }

.form-msg { font-size: 13.5px; min-height: 18px; margin: 2px 0 10px; }
.form-msg.error { color: var(--danger); }
.form-msg.ok { color: var(--ok); }

.info-box {
  display: flex; gap: 10px; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: 14px; padding: 12px 14px; font-size: 13px; color: var(--ink-soft); margin-bottom: 18px;
}
.info-box .ic { color: var(--terra); flex-shrink: 0; margin-top: 1px; }

.badge-lock {
  display: inline-flex; align-items: center; gap: 8px; background: var(--bg-2);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px;
  font-size: 12.5px; color: var(--ink-soft); margin: 14px 0 22px;
}

/* ===== Auth ===== */
.auth-wrap { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth-card {
  width: 100%; max-width: 940px; background: var(--paper); border: 1px solid var(--line);
  border-radius: 26px; box-shadow: var(--shadow); overflow: hidden;
  display: grid; grid-template-columns: 1.05fr 1fr;
}
.auth-form { padding: 44px 42px; display: flex; flex-direction: column; justify-content: center; }
.auth-media {
  background: url('/img/planner-scene.svg') center/cover no-repeat, var(--bg-2);
  min-height: 100%;
}
.auth-brand { margin-bottom: 20px; }
.auth-brand .mark { font-family: var(--display); font-size: 34px; color: var(--terra); line-height: 1; }
.auth-brand .name { letter-spacing: 5px; font-size: 12px; color: var(--terra-dark); margin-top: 2px; }
.auth-card h1.display { font-size: 40px; color: var(--ink); margin-bottom: 6px; }
.auth-sub { color: var(--ink-soft); font-size: 15px; margin: 0 0 4px; line-height: 1.5; }
.auth-tag { font-family: var(--script); font-size: 22px; color: var(--terra-soft); margin-top: 26px; line-height: 1.2; }
.heart { color: var(--terra-soft); }
.switch-row { margin-top: 16px; font-size: 14px; color: var(--ink-soft); }

/* ===== App shell ===== */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100dvh; }
.sidebar {
  background: var(--paper); border-right: 1px solid var(--line);
  padding: 24px 16px; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 4px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 12px 22px; }
.sidebar .brand .mark { font-family: var(--display); font-size: 26px; color: var(--terra); }
.sidebar .brand .name { letter-spacing: 4px; font-size: 12px; color: var(--terra-dark); }
.nav-item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 11px 14px; border: none; background: none; border-radius: 12px;
  color: var(--ink-soft); font-size: 14.5px; transition: background .12s, color .12s;
}
.nav-item .ic { color: var(--ink-faint); flex-shrink: 0; }
.nav-item:hover { background: var(--bg-2); color: var(--ink); }
.nav-item.active { background: var(--terra); color: #fff; }
.nav-item.active .ic { color: #fff; }
.nav-sep { flex: 1; }
.nav-item.logout { color: var(--ink-faint); margin-top: 4px; }

.topbar {
  display: none; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(251,247,239,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40;
}
.topbar .brand { display: flex; align-items: center; gap: 8px; }
.topbar .brand .mark { font-family: var(--display); font-size: 24px; color: var(--terra); }
.topbar .brand .name { letter-spacing: 3px; font-size: 11px; color: var(--terra-dark); }
.icon-btn { background: none; border: none; color: var(--ink-soft); padding: 8px; border-radius: 10px; line-height: 0; }
.icon-btn:hover { background: var(--bg-2); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--terra); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 14px; }

.main { min-width: 0; }
.content { max-width: 1040px; margin: 0 auto; padding: 30px 26px 90px; }

/* Drawer (mobile) */
.scrim { position: fixed; inset: 0; background: rgba(74,63,53,.42); z-index: 45; opacity: 0; pointer-events: none; transition: opacity .2s; }
.scrim.show { opacity: 1; pointer-events: auto; }

/* ===== Page headers ===== */
.page-h { margin-bottom: 22px; }
.page-h h1 { font-size: 30px; }
.page-h .sub { color: var(--ink-soft); font-size: 14.5px; margin-top: 4px; }
.greet { display: flex; align-items: baseline; gap: 8px; }
.greet .spark { color: var(--gold); }

/* ===== Cards ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card.pad { padding: 22px; }

/* Dashboard grid */
.dash { display: grid; grid-template-columns: 1fr; gap: 18px; }
.dash-row { display: grid; gap: 18px; grid-template-columns: 2fr 1fr; align-items: start; }
.dash-row.two { grid-template-columns: 1fr 1fr; }

/* Hero "registre a semana" */
.hero {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: linear-gradient(105deg, #f3e7d6 0%, #efe0cd 60%, #e9d7bf 100%);
  border: 1px solid var(--line); padding: 26px; display: grid; grid-template-columns: 1.4fr .9fr; gap: 12px; align-items: center;
}
.hero h2 { font-size: 24px; display: flex; align-items: center; gap: 10px; color: var(--ink); }
.hero p { color: var(--ink-soft); font-size: 14.5px; margin: 8px 0 18px; line-height: 1.5; max-width: 38ch; }
.hero .scene { height: 130px; background: url('/img/planner-scene.svg') center/cover; border-radius: 14px; border: 1px solid var(--line); }

/* Progress */
.progress-card { padding: 22px; display: flex; gap: 16px; align-items: center; position: relative; overflow: hidden; }
.progress-card .bloom { position: absolute; right: -10px; bottom: -14px; width: 120px; opacity: .5; }
.progress-card .wk { font-family: var(--display); font-size: 22px; color: var(--terra-dark); }
.progress-card .rng { font-size: 12.5px; color: var(--ink-faint); }
.bar { height: 9px; border-radius: 999px; background: var(--line-soft); overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--terra-soft), var(--terra)); border-radius: 999px; }
.progress-card .pct { font-family: var(--display); font-size: 20px; color: var(--ink); }

/* Quote */
.quote { padding: 24px; position: relative; }
.quote .mark { font-family: var(--display); font-size: 46px; color: var(--terra-soft); line-height: .5; }
.quote p { font-family: var(--display); font-size: 21px; color: var(--ink); line-height: 1.35; margin: 6px 0 0; }

/* Quick access */
.qa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.qa {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 18px 16px; text-align: left; transition: transform .12s, box-shadow .12s, border-color .12s;
}
.qa:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); border-color: var(--terra-soft); }
.qa .ic { width: 40px; height: 40px; border-radius: 11px; background: var(--bg-2); color: var(--terra);
  display: grid; place-items: center; margin-bottom: 12px; }
.qa .t { font-weight: 600; font-size: 14.5px; color: var(--ink); }
.qa .d { font-size: 12.5px; color: var(--ink-faint); margin-top: 2px; }

.section-title { font-family: var(--display); font-size: 20px; color: var(--ink); margin: 6px 0 14px; }

/* Lists (compromissos / recent notes) */
.mini-list { display: flex; flex-direction: column; }
.mini-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.mini-item:last-child { border-bottom: none; }
.mini-item .ic { color: var(--terra); margin-top: 2px; }
.mini-item .t { font-weight: 600; font-size: 14px; }
.mini-item .m { font-size: 12.5px; color: var(--ink-faint); }
.empty-soft { color: var(--ink-faint); font-size: 13.5px; text-align: center; padding: 22px 8px; }

/* ===== Calendar ===== */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.month-nav .m-name { font-family: var(--display); font-size: 22px; color: var(--terra-dark); }
.weeks-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
.week-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 16px; text-align: left; transition: transform .12s, box-shadow .12s, border-color .12s; }
.week-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-sm); border-color: var(--terra-soft); }
.week-card .wn { font-family: var(--display); font-size: 15px; color: var(--terra-dark); }
.week-card .wn b { display: block; font-size: 30px; color: var(--ink); font-weight: 600; }
.week-card .wr { font-size: 12px; color: var(--ink-faint); margin-top: 4px; }
.week-card .badges { display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap; }
.chip-mini { font-size: 11px; padding: 3px 9px; border-radius: 999px; background: var(--bg-2); color: var(--ink-soft); }
.chip-mini.on { background: #e7dbc4; color: var(--terra-dark); }
.week-card.now { border-color: var(--terra); box-shadow: 0 0 0 1px var(--terra); }

/* ===== Week detail ===== */
.back-link { background: none; border: none; color: var(--terra-dark); font-size: 14px; padding: 0; margin-bottom: 12px; }
.uploader { border: 1.5px dashed var(--terra-soft); border-radius: var(--radius-sm); padding: 24px; text-align: center;
  background: var(--card); color: var(--ink-soft); margin: 14px 0 22px; }
.uploader .ic { color: var(--terra); }
.uploader.busy { opacity: .6; pointer-events: none; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.photo-item { position: relative; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--line); background: var(--white); }
.photo-item img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.photo-item .cap { font-size: 12px; padding: 7px 9px; color: var(--ink-soft); }
.photo-item .del { position: absolute; top: 7px; right: 7px; background: rgba(74,63,53,.65); color: #fff;
  border: none; border-radius: 9px; width: 30px; height: 30px; line-height: 0; }

/* ===== Notes ===== */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar input[type=search] { flex: 1; min-width: 170px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--white); font-family: inherit; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 8px 15px; font-size: 13px; color: var(--ink-soft); }
.chip.active { background: var(--terra); color: #fff; border-color: var(--terra); }
.note-list { display: flex; flex-direction: column; gap: 12px; }
.note-item { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 15px 17px; }
.note-item h3 { font-size: 16px; }
.note-item .meta { font-size: 12px; color: var(--ink-faint); margin-top: 3px; }
.note-item p { margin: 8px 0 0; font-size: 14px; color: var(--ink-soft); white-space: pre-wrap;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* ===== Empty / placeholder pages ===== */
.empty { text-align: center; color: var(--ink-soft); padding: 48px 20px; }
.empty .big { font-size: 42px; }
.soon {
  text-align: center; padding: 56px 24px; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.soon .bloom { width: 120px; margin: 0 auto 14px; display: block; opacity: .8; }
.soon h2 { font-family: var(--display); font-size: 26px; margin-bottom: 8px; }
.soon p { color: var(--ink-soft); font-size: 14.5px; max-width: 42ch; margin: 0 auto; line-height: 1.55; }
.soon .tag { display: inline-block; margin-top: 16px; font-size: 12px; color: var(--terra-dark);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; }

/* ===== Profile ===== */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 22px; }
.profile-head .av { width: 64px; height: 64px; border-radius: 50%; background: var(--terra); color: #fff;
  display: grid; place-items: center; font-family: var(--display); font-size: 28px; }

/* ===== FAB ===== */
.fab { position: fixed; right: 22px; bottom: 26px; z-index: 30; width: 56px; height: 56px; border-radius: 50%;
  border: none; background: var(--terra); color: #fff; font-size: 26px; box-shadow: var(--shadow); line-height: 0; }

/* ===== Modal ===== */
.modal-back { position: fixed; inset: 0; background: rgba(74,63,53,.42); display: grid; place-items: end center; z-index: 60; }
.modal { width: 100%; max-width: 620px; background: var(--paper); border-radius: 22px 22px 0 0; padding: 22px; max-height: 92dvh; overflow: auto; box-shadow: var(--shadow); }
@media (min-width: 640px) { .modal-back { place-items: center; } .modal { border-radius: 22px; } }
.modal h2 { font-family: var(--display); font-size: 24px; margin-bottom: 14px; }
.modal .row { display: flex; gap: 10px; }
.modal .row .field { flex: 1; }

/* ===== Toast ===== */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; max-width: 90%; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive ===== */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .topbar { display: flex; }
  .sidebar {
    position: fixed; top: 0; left: 0; z-index: 50; width: 264px; height: 100dvh;
    transform: translateX(-100%); transition: transform .22s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .content { padding: 22px 16px 90px; }
  .dash-row, .dash-row.two { grid-template-columns: 1fr; }
  .hero { grid-template-columns: 1fr; }
  .hero .scene { height: 110px; }
  .auth-card { grid-template-columns: 1fr; max-width: 440px; }
  .auth-media { display: none; }
  .auth-form { padding: 34px 28px; }
  .page-h h1 { font-size: 26px; }
  .auth-card h1.display { font-size: 34px; }
}
