/* ===========================================================================
   SmartLaw — design system  ·  modern legal-tech (Jusfy) × techy (Pumpkin)
   Light + Night mode via [data-theme].  Mobile-first.
   =========================================================================== */
:root {
  --bg:        #f1f5f3;
  --bg-glow:   rgba(12,155,102,.10);
  --surface:   #ffffff;
  --surface-2: #f3f7f5;
  --surface-3: #e9f1ed;
  --ink:       #0d1a16;
  --ink-soft:  #394a44;
  --muted:     #6a7872;
  --primary:   #0c9b66;
  --primary-d: #0a7e53;
  --primary-l: #13b87b;
  --primary-ghost: rgba(12,155,102,.10);
  --accent:    #0bb39a;
  --danger:    #c0392b;
  --danger-bg: #fbeeec;
  --ok:        #1f8a55;
  --border:    #e4ece8;
  --border-2:  #d2ded8;
  --shadow-sm: 0 1px 2px rgba(13,26,22,.05);
  --shadow:    0 1px 2px rgba(13,26,22,.04), 0 10px 30px rgba(13,26,22,.07);
  --shadow-lg: 0 24px 60px rgba(13,26,22,.16);
  --glow:      0 8px 24px rgba(12,155,102,.26);
  --ring:      0 0 0 4px rgba(12,155,102,.16);
  --header-bg: rgba(255,255,255,.72);
  --radius:    16px;
  --radius-sm: 11px;
  --maxw:      1280px;
  --sans:      "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono:      "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
[data-theme="dark"] {
  --bg:        #0a1110;
  --bg-glow:   rgba(24,205,140,.14);
  --surface:   #111b18;
  --surface-2: #16221e;
  --surface-3: #1c2b25;
  --ink:       #e9f1ed;
  --ink-soft:  #b3c1bb;
  --muted:     #7f8e88;
  --primary:   #18cd8c;
  --primary-d: #12b77c;
  --primary-l: #3ce0a4;
  --primary-ghost: rgba(24,205,140,.14);
  --accent:    #1fd3bd;
  --danger:    #ff8a7a;
  --danger-bg: rgba(192,57,43,.16);
  --ok:        #4fd99a;
  --border:    rgba(255,255,255,.09);
  --border-2:  rgba(255,255,255,.16);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
  --shadow:    0 2px 6px rgba(0,0,0,.40), 0 18px 44px rgba(0,0,0,.45);
  --shadow-lg: 0 30px 70px rgba(0,0,0,.6);
  --glow:      0 8px 30px rgba(24,205,140,.34);
  --ring:      0 0 0 4px rgba(24,205,140,.22);
  --header-bg: rgba(10,17,16,.64);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--sans);
  background:
    radial-gradient(1100px 520px at 82% -8%, var(--bg-glow), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, var(--primary-ghost), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-size: 16px; line-height: 1.55; min-height: 100vh;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  transition: background-color .3s ease, color .3s ease;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--primary-ghost); }

.eyebrow { font-family: var(--mono); font-weight: 600; font-size: 11.5px; letter-spacing: .18em;
  text-transform: uppercase; color: var(--primary); }

/* ---------- header (glassy sticky) -------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.site-header .wrap { max-width: var(--maxw); margin: 0 auto; padding: 11px clamp(14px,4vw,26px);
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px;
  color: #fff; background: linear-gradient(135deg, var(--primary-l), var(--primary-d));
  box-shadow: var(--glow); }
.brand-text { display: flex; flex-direction: column; line-height: 1.12; }
.brand .logo { font-weight: 800; font-size: 21px; letter-spacing: -.02em; color: var(--ink); }
.brand .logo .law { color: var(--primary); }
.brand .tagline { color: var(--muted); font-size: 11.5px; margin-top: 1px; }

.site-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.site-nav a { color: var(--ink-soft); padding: 9px 14px; border-radius: 999px; font-size: 14.5px; font-weight: 600;
  text-decoration: none; transition: background .15s, color .15s; white-space: nowrap; }
.site-nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.site-nav a.pill-accent { color: var(--primary); background: var(--primary-ghost); }
.site-nav a.pill-accent:hover { background: var(--primary-ghost); filter: brightness(.97); }
.theme-toggle { display: grid; place-items: center; width: 40px; height: 40px; margin-left: 4px;
  border-radius: 11px; border: 1px solid var(--border-2); background: var(--surface); color: var(--ink-soft);
  cursor: pointer; transition: background .15s, color .15s, border-color .15s; }
.theme-toggle:hover { background: var(--surface-2); color: var(--primary); border-color: var(--primary); }
[data-theme="light"] .theme-toggle .ico-sun { display: none; }
[data-theme="dark"]  .theme-toggle .ico-moon { display: none; }

/* ---------- layout ------------------------------------------------------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: clamp(18px,4vw,30px); }
.muted { color: var(--muted); } .small { font-size: 13px; }

/* ---------- hero + steps ------------------------------------------------- */
.hero { margin: 8px 2px 18px; }
.hero .eyebrow { display: inline-block; margin-bottom: 12px; }
.hero h1 { font-weight: 800; letter-spacing: -.025em; font-size: clamp(26px,5.4vw,40px);
  line-height: 1.08; margin: 0 0 10px; color: var(--ink); }
.hero h1 .grad { background: linear-gradient(120deg, var(--primary-l), var(--accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.hero p { margin: 0; color: var(--muted); font-size: clamp(15px,2.4vw,17px); max-width: 62ch; }

.steps { display: grid; grid-template-columns: 1fr; gap: 10px; margin: 18px 0 24px; }
@media (min-width: 720px) { .steps { grid-template-columns: repeat(3,1fr); } }
.step { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-sm); }
.step .num { font-family: var(--mono); font-weight: 600; font-size: 13px; color: var(--primary);
  background: var(--primary-ghost); border-radius: 8px; padding: 4px 9px; flex: none; }
.step .txt b { display: block; font-size: 14.5px; color: var(--ink); }
.step .txt span { font-size: 13px; color: var(--muted); }

/* ---------- tabs --------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 22px;
  overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs button { background: none; border: none; font-family: var(--sans); font-size: 15px; font-weight: 600;
  padding: 12px 18px; color: var(--muted); cursor: pointer; border-bottom: 2.5px solid transparent;
  margin-bottom: -1px; border-radius: 9px 9px 0 0; white-space: nowrap; min-height: 44px; }
.tabs button:hover { color: var(--ink); background: var(--surface-2); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; animation: fade .28s ease; }
.tab-panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* ---------- editor split ------------------------------------------------- */
.editor-grid { display: grid; grid-template-columns: 1fr; gap: 20px; align-items: start; }
@media (min-width: 960px) { .editor-grid { grid-template-columns: 400px 1fr; } }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: clamp(16px,3vw,22px); }
.panel h2 { font-weight: 700; letter-spacing: -.01em; font-size: 18px; margin: 0 0 4px; color: var(--ink); }
.panel .hint { color: var(--muted); font-size: 13.5px; margin: 0 0 16px; }
@media (min-width: 960px) { .panel.library { position: sticky; top: 78px; } }

.field { margin-bottom: 16px; }
.field label { display: block; font-family: var(--mono); font-weight: 600; font-size: 11px; letter-spacing: .1em;
  text-transform: uppercase; margin-bottom: 8px; color: var(--muted); }
select, input[type=text], input[type=password], textarea {
  width: 100%; padding: 12px 13px; font-family: var(--sans); font-size: 16px; font-weight: 500;
  border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--surface-2);
  color: var(--ink); transition: border-color .15s, box-shadow .15s, background .15s;
  -webkit-appearance: none; appearance: none; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236a7872' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px; }
select:focus, input:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); background: var(--surface); }
select:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- preview ("document paper") ----------------------------------- */
.preview-wrap { margin-top: 4px; }
.preview { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2);
  padding: 16px 18px; max-height: 46vh; overflow: auto; font-size: 14px; color: var(--ink-soft); }
.preview:empty::before { content: "Selecione uma seção e uma tag para visualizar o texto.";
  color: var(--muted); font-style: italic; }
.preview p { margin: 0 0 8px; }
[data-theme="dark"] .preview { background: #fbfdfb; color: #1b2330; } /* legal text stays on light paper */

/* ---------- buttons ------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; gap: 8px; justify-content: center; font-family: var(--sans);
  font-size: 15px; font-weight: 700; cursor: pointer; padding: 12px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; min-height: 46px; text-decoration: none; line-height: 1;
  transition: transform .05s, background .15s, box-shadow .15s, border-color .15s, filter .15s; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn .arrow { transition: transform .15s; }
.btn:hover .arrow { transform: translateX(3px); }
.btn-primary { background: linear-gradient(120deg, var(--primary-l), var(--primary-d)); color: #fff; box-shadow: var(--glow); }
.btn-primary:hover { filter: brightness(1.05); text-decoration: none; }
.btn-accent { background: linear-gradient(120deg, var(--accent), var(--primary)); color: #fff; box-shadow: var(--glow); }
.btn-accent:hover { filter: brightness(1.05); text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--ink-soft); border-color: var(--border-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.btn-danger { background: var(--surface); color: var(--danger); border-color: var(--border-2); }
.btn-danger:hover { background: var(--danger-bg); text-decoration: none; }
.btn-sm { padding: 8px 13px; font-size: 13.5px; min-height: 38px; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; filter: none; }
.btn-block { width: 100%; }

.editor-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin-top: 16px; }
.editor-toolbar .field { margin-bottom: 0; } .editor-toolbar .grow { flex: 1; min-width: 150px; }

/* ---------- scratch ------------------------------------------------------ */
#scratch { width: 100%; min-height: 56vh; padding: 18px 20px; border: 1px solid var(--border);
  border-radius: var(--radius); font-family: var(--sans); font-size: 16px; line-height: 1.7;
  background: var(--surface); color: var(--ink); resize: vertical; box-shadow: var(--shadow); }
.autosave-note { color: var(--muted); font-size: 12.5px; margin-top: 8px; }

/* ---------- admin -------------------------------------------------------- */
.admin-shell { max-width: 1080px; margin: 0 auto; padding: clamp(18px,4vw,30px); }
.admin-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.admin-bar h1 { font-weight: 800; letter-spacing: -.02em; font-size: clamp(20px,4vw,26px); margin: 0; }
.admin-bar .spacer { flex: 1; }
.breadcrumb { font-size: 13.5px; color: var(--muted); margin-bottom: 14px; } .breadcrumb a { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 18px; overflow: hidden; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center;
  gap: 12px; flex-wrap: wrap; background: var(--surface-2); }
.card-head h2 { font-weight: 700; font-size: 18px; margin: 0; }
.card-body { padding: 18px 20px; }

.list { list-style: none; margin: 0; padding: 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.list-row:last-child { border-bottom: none; } .list-row:hover { background: var(--surface-2); }
.list-row .grow { flex: 1; min-width: 140px; }
.list-row .name { font-weight: 700; color: var(--ink); } .list-row .name a { color: var(--ink); }
.list-row .name a:hover { color: var(--primary); }
.list-row .meta { color: var(--muted); font-size: 13px; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.count-badge { display: inline-block; min-width: 26px; text-align: center; padding: 3px 11px; background: var(--primary-ghost);
  border: 1px solid transparent; border-radius: 999px; font-size: 12.5px; font-weight: 600; color: var(--primary); white-space: nowrap; }
.move-btns { display: inline-flex; flex-direction: column; gap: 3px; }
.move-btns button { border: 1px solid var(--border-2); background: var(--surface); color: var(--muted); width: 30px; height: 22px;
  line-height: 1; cursor: pointer; border-radius: 6px; font-size: 11px; }
.move-btns button:hover:not(:disabled) { background: var(--surface-2); color: var(--primary); }
.move-btns button:disabled { opacity: .35; cursor: not-allowed; }
.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.inline-form input[type=text] { flex: 1; min-width: 180px; }
form.confirm-del { display: inline; }

/* ---------- login -------------------------------------------------------- */
.login-wrap { min-height: 64vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 410px; max-width: 94vw; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: clamp(24px,6vw,36px); }
.login-card .lock { width: 54px; height: 54px; border-radius: 15px; display: grid; place-items: center; margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--primary-l), var(--primary-d)); color: #fff; box-shadow: var(--glow); }
.login-card h1 { font-weight: 800; letter-spacing: -.01em; font-size: 22px; margin: 0 0 6px; text-align: center; }
.login-card p.sub { text-align: center; color: var(--muted); margin: 0 0 22px; font-size: 13.5px; }

/* ---------- alerts ------------------------------------------------------- */
.alert { padding: 12px 15px; border-radius: var(--radius-sm); font-size: 14.5px; margin-bottom: 16px; border: 1px solid; }
.alert-error { background: var(--danger-bg); border-color: var(--border-2); color: var(--danger); }
.alert-ok { background: var(--primary-ghost); border-color: var(--border-2); color: var(--ok); }
.help-box { background: var(--surface-2); border: 1px dashed var(--border-2); border-radius: var(--radius-sm);
  padding: 13px 15px; font-size: 13.5px; color: var(--ink-soft); margin-bottom: 16px; }

/* ---------- backup calendar --------------------------------------------- */
.backup-grid { display: grid; grid-template-columns: 1fr; gap: 18px; align-items: start; }
@media (min-width: 820px) { .backup-grid { grid-template-columns: 1.3fr 1fr; } }
.cal-nav { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.cal-nav button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border-2);
  background: var(--surface); color: var(--ink-soft); cursor: pointer; font-size: 17px; line-height: 1; }
.cal-nav button:hover { background: var(--surface-2); color: var(--primary); }
.cal-nav #cal-title { min-width: 132px; text-align: center; font-size: 14.5px; }

.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-wd { text-align: center; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted); padding-bottom: 4px; }
.cal-cell { position: relative; aspect-ratio: 1 / 1; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--ink-soft); cursor: default; display: flex; align-items: center;
  justify-content: center; font-size: 14px; padding: 0; transition: background .12s, border-color .12s, transform .04s; }
.cal-cell.empty { border: none; background: none; }
.cal-cell.has-backup { cursor: pointer; color: var(--ink); font-weight: 600; border-color: var(--border-2); }
.cal-cell.has-backup:hover { background: var(--primary-ghost); border-color: var(--primary); }
.cal-cell.has-backup:active { transform: translateY(1px); }
.cal-cell.today { box-shadow: inset 0 0 0 1.5px var(--accent); }
.cal-cell.selected { background: var(--primary); border-color: var(--primary); color: #fff; }
.cal-cell:disabled { cursor: default; opacity: .55; }
.cal-num { line-height: 1; }
.cal-dot { position: absolute; bottom: 6px; left: 50%; transform: translateX(-50%);
  width: 5px; height: 5px; border-radius: 50%; background: var(--primary); }
.cal-cell.selected .cal-dot { background: #fff; }
.cal-legend { margin: 14px 0 0; font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.cal-legend .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); display: inline-block; }

.day-list { display: flex; flex-direction: column; gap: 10px; }
.snap { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-2); flex-wrap: wrap; }
.snap-info { display: flex; align-items: center; gap: 9px; flex: 1; min-width: 150px; flex-wrap: wrap; }
.snap-time { font-weight: 700; font-size: 15px; }
.kind-badge { font-family: var(--mono); font-size: 10px; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 8px; border-radius: 999px; background: var(--surface-3); color: var(--muted); }
.kind-badge.kind-auto { background: var(--primary-ghost); color: var(--primary); }
.kind-badge.kind-pre { background: var(--danger-bg); color: var(--danger); }

footer.site-footer { text-align: center; color: var(--muted); font-size: 12.5px; padding: 34px 16px 44px; }

@media (max-width: 560px) {
  .brand .tagline { display: none; }
  .site-header .wrap { padding: 9px 14px; gap: 8px; }
  .editor-toolbar .btn { flex: 1 1 100%; }
  .list-row { padding: 12px 14px; }
}
