/* Studio — tema compartilhado entre o hub e os apps.
   Servido por cada app em /theme/theme.css. */

/* --- Tokens --- */
:root {
  --bg: #0e0d0c;
  --surface: #171614;
  --surface-2: #1f1d1b;
  --line: #2c2a27;
  --line-strong: #44403b;
  --ink: #f2ede4;
  --muted: #8f887d;
  --faint: #5a554e;
  --accent: #e2483d;
  --accent-soft: rgba(226, 72, 61, 0.14);
  --done: #c9b88f;
  --radius: 14px;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* garante que [hidden] vença regras de display (modal, lightbox) */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  padding: 0 clamp(16px, 4vw, 56px) 48px;
  max-width: 1440px;
  margin-inline: auto;
  -webkit-font-smoothing: antialiased;
}

/* textura sutil de papel */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at top, rgba(255, 255, 255, 0.04), transparent 60%);
  z-index: -1;
}

button { font: inherit; color: inherit; }
a { color: inherit; }

.eyebrow {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* --- Header --- */
.top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 24px 40px;
  padding-top: clamp(32px, 6vw, 72px);
  padding-bottom: 28px;
}

h1 {
  margin: 0;
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(44px, 7vw, 88px);
  line-height: 0.95;
  letter-spacing: -0.02em;
}
h1 em { font-style: italic; color: var(--accent); }

/* barra de navegação entre apps (← Studio · outras páginas) */
.app-nav {
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  padding-top: 20px;
  font-size: 13px;
}
.app-nav a { color: var(--muted); text-decoration: none; transition: color 0.15s; }
.app-nav a:hover, .app-nav a.is-current { color: var(--ink); }
.app-nav + .top { padding-top: clamp(20px, 4vw, 48px); }

.section-title {
  margin: 0 0 16px;
  font-family: var(--serif);
  font-weight: 400;
  font-size: 28px;
}
.section-title em { font-style: italic; color: var(--accent); }

/* --- Toolbar --- */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}
.filters, .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.chip, .btn {
  border: 1px solid var(--line-strong);
  background: transparent;
  border-radius: 99px;
  padding: 7px 16px;
  font-size: 13px;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.chip { color: var(--muted); border-color: var(--line); }
.chip:hover, .btn:hover { border-color: var(--ink); color: var(--ink); }
.chip.is-active { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn-accent { background: var(--accent); border-color: var(--accent); }
.btn-accent:hover { background: transparent; }
.btn-danger:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger.is-confirming { background: var(--accent); border-color: var(--accent); color: var(--ink); }

/* --- Seletor segmentado (escolha com um clique) --- */
.segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 1px;                       /* o fundo vira a linha divisória */
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.segmented button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 6px;
  border: none;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.segmented button:hover { color: var(--ink); }
.segmented button.is-active { background: var(--ink); color: var(--bg); }
.segmented button:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }

/* --- Campos --- */
.input, .textarea, .select {
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
}
.textarea { resize: vertical; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--line-strong); }

kbd {
  font: 11px var(--sans);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 1px 5px;
}
code { font-size: 12px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }

.hint {
  margin-top: 28px;
  text-align: center;
  font-size: 13px;
  color: var(--faint);
}

/* --- Lightbox --- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr 320px auto;
  align-items: center;
  gap: 24px;
  padding: 32px;
  background: rgba(8, 8, 7, 0.96);
  backdrop-filter: blur(6px);
}
.lb-figure {
  margin: 0;
  height: 100%;
  display: grid;
  place-items: center;
  min-width: 0;
}
.lb-figure img {
  max-height: calc(100vh - 64px);
  max-width: 100%;
  object-fit: contain;
  border-radius: 6px;
}
.lb-panel h2 {
  margin: 0 0 20px;
  font-family: var(--serif);
  font-weight: 400;
  font-style: italic;
  font-size: 44px;
  line-height: 1;
}
.lb-panel textarea, .lb-panel input {
  width: 100%;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  font: inherit;
  font-size: 14px;
}
.lb-panel textarea { resize: vertical; }
.lb-panel textarea:focus, .lb-panel input:focus { outline: none; border-color: var(--line-strong); }
.lb-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }

.lb-close, .lb-nav {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--muted);
  transition: color 0.15s;
}
.lb-close:hover, .lb-nav:hover { color: var(--ink); }
.lb-close { position: absolute; top: 12px; right: 20px; font-size: 36px; }
.lb-nav { font-size: 48px; padding: 0 8px; }
.lb-nav:disabled { visibility: hidden; }

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 8, 7, 0.8);
}
.modal-box {
  max-width: 440px;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
}
.modal-box h2 { margin: 0 0 8px; font-family: var(--serif); font-weight: 400; font-size: 28px; }
.modal-box p { margin: 0; color: var(--muted); font-size: 14px; }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  background: var(--ink);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 99px;
  font-size: 13px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}
.toast.is-error { background: var(--accent); color: var(--ink); }

/* --- Responsivo --- */
@media (max-width: 860px) {
  .top { grid-template-columns: 1fr; }
  .lightbox {
    grid-template-columns: auto 1fr auto;
    grid-template-rows: 1fr auto;
    overflow-y: auto;
    padding: 48px 12px 16px;
  }
  .lb-figure { grid-column: 2; }
  .lb-figure img { max-height: 60vh; }
  .lb-panel { grid-column: 1 / -1; grid-row: 2; }
  .lb-prev { grid-column: 1; grid-row: 1; }
  .lb-next { grid-column: 3; grid-row: 1; }
  .lb-panel h2 { font-size: 32px; }
}

/* ===== Menu lateral (Sketchbook, Notebook) — página com <div class="shell"> ===== */

/* --- Layout: menu lateral + conteúdo --- */
body:has(> .shell) { max-width: none; padding: 0; }
.shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}
.content {
  width: 100%;
  padding: 0 clamp(16px, 4vw, 56px) 48px;
}

/* --- Menu lateral --- */
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 28px;
  padding: 24px 18px 20px;
  border-right: 1px solid var(--line);
  background: rgba(23, 22, 20, 0.6);
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}
.sb-head { display: flex; justify-content: space-between; align-items: center; }
.sb-back { font-size: 13px; color: var(--muted); text-decoration: none; transition: color 0.15s; }
.sb-back:hover { color: var(--ink); }
.sb-close { display: none; background: none; border: none; font-size: 28px; line-height: 1; color: var(--muted); cursor: pointer; }

.sb-search { position: relative; display: block; }
.sb-search .input { border-radius: 99px; padding: 8px 36px 8px 16px; }
.sb-search kbd { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.sb-search .input:focus + kbd { opacity: 0; }

/* Seções principais em serifa: hierarquia editorial */
.sb-views { display: grid; gap: 2px; }
.sb-view {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font-family: var(--serif);
  font-size: 22px;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}
.sb-view span { font-family: var(--sans); font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.sb-view:hover { color: var(--ink); background: var(--surface-2); }
.sb-view.is-active { color: var(--ink); font-style: italic; }

.sb-section { display: grid; gap: 6px; }
.sb-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 0 2px;
  padding: 0 10px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}
summary.sb-title { cursor: pointer; list-style: none; }
summary.sb-title::-webkit-details-marker { display: none; }
summary.sb-title::after { content: '+'; font-size: 14px; letter-spacing: 0; }
details[open] > summary.sb-title::after { content: '−'; }
summary.sb-title:hover { color: var(--muted); }
.sb-add {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: none;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  color: var(--muted);
  transition: color 0.15s, border-color 0.15s;
}
.sb-add:hover { color: var(--ink); border-color: var(--ink); }

.sb-list { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1px; }
.sb-more { justify-self: start; margin: 4px 10px 0; font-size: 12px; }
.sb-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  border-radius: 8px;
  background: none;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  transition: color 0.15s, background 0.15s;
}
.sb-link:hover { color: var(--ink); background: var(--surface-2); }
.sb-link.is-active { color: var(--ink); background: var(--surface-2); }
/* marca ativa: traço de tinta na margem */
.sb-view { position: relative; }
.sb-link.is-active::before, .sb-view.is-active::before {
  content: '';
  position: absolute;
  left: -18px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}
.sb-label { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.sb-link.is-active .sb-count { color: var(--muted); }
.sb-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; border: 1.5px solid var(--done); }
.sb-link.is-active .sb-dot { background: var(--done); }
.sb-empty { margin: 0; padding: 4px 10px; font-size: 13px; color: var(--faint); }

.sb-tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px 0; }
.sb-tags .chip { padding: 3px 10px; font-size: 12px; }
.chip-count { opacity: 0.6; font-size: 11px; margin-left: 2px; }

.sb-foot {
  display: grid;
  justify-items: start;
  gap: 6px;
  margin-top: auto;
  padding: 16px 10px 0;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.sb-foot a, .sb-foot .link-btn { color: var(--muted); text-decoration: none; }
.sb-foot a:hover, .sb-foot .link-btn:hover { color: var(--ink); }

.sidebar :focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.link-btn {
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--line-strong);
}
.link-btn:hover { color: var(--ink); text-decoration-color: currentColor; }

/* --- Barra do topo no mobile (abre a gaveta) --- */
.mobile-bar { display: none; }
.mobile-title { font-family: var(--serif); font-size: 20px; }
.mobile-title em { color: var(--accent); }

/* Menu vira gaveta */
@media (max-width: 960px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 9;
    width: min(300px, 86vw);
    background: var(--surface);
    box-shadow: 12px 0 40px rgba(0, 0, 0, 0.5);
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 0.25s cubic-bezier(.2, .8, .2, 1), visibility 0.25s;
  }
  .sidebar.is-open { transform: none; visibility: visible; }
  .sb-close { display: block; }
  .sidebar-backdrop { position: fixed; inset: 0; z-index: 8; background: rgba(8, 8, 7, 0.6); }

  .mobile-bar {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0 calc(-1 * clamp(16px, 4vw, 56px));
    padding: 10px clamp(16px, 4vw, 56px);
    background: var(--bg);
    border-bottom: 1px solid var(--line);
  }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
}
