/* ============================================
   Calendário de Conteúdo IA — Styles
   Design Direction: WARM ORGANIC (Hard Rule #16 — unused; library #4)
   Brief: a tactile paper-agenda / planner. Warm off-white paper (#f4ede2),
   clay/terracotta primary, sage ink secondary, soft gold details. Humanist
   serif headings (treated Georgia-class) + warm humanist sans body. Rounded
   tactile panels, soft layered shadows, a subtle paper grain, hand-drawn
   marker/washi accents. Signature: a tactile monthly planner grid on warm paper
   with hand-drawn day cells + a marker-underline motif. No external fonts/images
   — fully self-contained (CSP font-src 'self').
   ============================================ */

:root {
  --paper: #f4ede2;
  --paper-2: #ece2d1;
  --card: #fbf6ec;
  --card-raised: #fffdf8;
  --ink: #2c271f;
  --ink-soft: #4d463b;
  --muted: #756a58;
  --faint: #9c8f78;

  --clay: #c1654a;
  --clay-deep: #a8502f;
  --clay-soft: #ecc8b8;
  --clay-wash: #f6e4da;
  --sage: #6f8a6a;
  --sage-deep: #4f6849;
  --sage-soft: #d4dccd;
  --gold: #b08d3e;
  --gold-soft: #e7d6ab;

  --line: #e4d8c4;
  --line-strong: #d6c5a8;

  --shadow-s: 0 1px 2px rgba(78,58,30,.06), 0 4px 10px -6px rgba(78,58,30,.18);
  --shadow: 0 2px 4px rgba(78,58,30,.06), 0 16px 36px -20px rgba(78,58,30,.32);
  --shadow-lift: 0 4px 8px rgba(78,58,30,.08), 0 26px 50px -22px rgba(78,58,30,.4);

  --r-s: 10px;
  --r: 16px;
  --r-l: 24px;
  --r-pill: 999px;

  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --maxw: 1240px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  position: relative;
}

/* paper grain — subtle, self-contained */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: .5;
  background-image:
    radial-gradient(rgba(120,95,55,.05) 1px, transparent 1px),
    radial-gradient(rgba(120,95,55,.035) 1px, transparent 1px);
  background-size: 7px 7px, 13px 13px;
  background-position: 0 0, 4px 6px;
}
/* warm corner light */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(1100px 700px at 12% -8%, rgba(193,101,74,.10), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(176,141,62,.09), transparent 55%);
}
.bg-gradient { display: none; }

.screen { display: none; position: relative; z-index: 1; }
.screen.active { display: block; }

/* ============ Typography helpers ============ */
h1, h2, h3, h4 { font-family: var(--serif); font-weight: 700; letter-spacing: -.01em; line-height: 1.18; color: var(--ink); }
.subtitle { color: var(--muted); font-size: 16px; }
.mono-label {
  font-family: var(--sans);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--clay-deep);
}

/* hand-drawn marker underline — highlighter stroke behind the text.
   display:inline + box-decoration-break:clone so the stroke renders correctly
   under EVERY wrapped line (a positioned ::after on an inline-block only ever
   sits under the last line, which breaks as soon as the heading wraps). */
.marker {
  display: inline;
  box-decoration-break: clone;
  -webkit-box-decoration-break: clone;
  padding: 0 .06em;
  background-image: linear-gradient(100deg, var(--clay-soft) 0%, var(--clay-soft) 92%, transparent 100%);
  background-repeat: no-repeat;
  background-size: 100% 40%;
  background-position: 0 86%;
}
.gradient-text { color: var(--ink); }

/* ============ Buttons ============ */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, filter .15s;
  padding: 13px 24px;
}
.btn-primary {
  background: var(--clay);
  color: #fff;
  box-shadow: 0 2px 0 var(--clay-deep), var(--shadow-s);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 0 var(--clay-deep), var(--shadow); }
.btn-primary:active:not(:disabled) { transform: translateY(0); box-shadow: 0 1px 0 var(--clay-deep); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn-secondary {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line-strong);
}
.btn-secondary:hover { background: var(--card-raised); border-color: var(--clay); color: var(--clay-deep); }
.btn-danger { background: transparent; color: var(--clay-deep); border: 1.5px solid var(--clay-soft); }
.btn-danger:hover { background: var(--clay-wash); }
.btn-ghost { background: transparent; color: var(--muted); padding: 8px 12px; }
.btn-ghost:hover { color: var(--clay-deep); }

.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--line);
  background: var(--card-raised);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .15s ease;
  text-decoration: none;
}
.btn-icon:hover { border-color: var(--clay); color: var(--clay-deep); transform: translateY(-1px); box-shadow: var(--shadow-s); }

/* ============ GATE SCREEN ============ */
#gate-screen.active, #key-screen.active { display: flex; }
#gate-screen, #key-screen {
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 28px 20px;
}
.gate-container, .key-container {
  width: 100%;
  max-width: 460px;
  background: var(--card-raised);
  border: 1.5px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow-lift);
  padding: 42px 38px;
  position: relative;
}
/* washi-tape accent on the gate card */
.gate-container::before {
  content: "";
  position: absolute;
  top: -13px; left: 50%;
  width: 116px; height: 26px;
  transform: translateX(-50%) rotate(-2deg);
  background: repeating-linear-gradient(45deg, rgba(193,101,74,.55) 0 8px, rgba(193,101,74,.38) 8px 16px);
  border-radius: 3px;
  opacity: .8;
  box-shadow: var(--shadow-s);
}
.gate-header { text-align: center; margin-bottom: 26px; }
.gate-header h1 { font-size: 30px; margin-bottom: 10px; }
.gate-header .subtitle { font-size: 15px; margin-bottom: 16px; }
.community-badge {
  display: inline-block;
  background: var(--sage-soft);
  color: var(--sage-deep);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  padding: 6px 14px;
  border-radius: var(--r-pill);
}
.gate-form .form-group { margin-bottom: 16px; }
.gate-form label, .key-input-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin-bottom: 7px;
}
.gate-form input, .key-input-wrapper input, .field-input, select.field-input {
  width: 100%;
  background: var(--card);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-s);
  padding: 13px 15px;
  font-size: 15px;
  color: var(--ink);
  font-family: var(--sans);
  transition: border-color .15s, box-shadow .15s;
}
.gate-form input:focus, .key-input-wrapper input:focus, .field-input:focus {
  outline: none;
  border-color: var(--clay);
  box-shadow: 0 0 0 3px var(--clay-wash);
}
.gate-form button[type="submit"] { width: 100%; margin-top: 8px; }
.gate-footer { text-align: center; margin-top: 20px; font-size: 14px; color: var(--muted); }
.gate-footer a, .key-info a { color: var(--clay-deep); font-weight: 600; }
.error-message {
  background: var(--clay-wash);
  color: var(--clay-deep);
  border: 1px solid var(--clay-soft);
  border-radius: var(--r-s);
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 14px;
  text-align: center;
}

/* ============ KEY SCREEN ============ */
.key-container h2 { font-size: 24px; margin-bottom: 8px; text-align: center; }
.key-container > .subtitle { text-align: center; margin-bottom: 22px; font-size: 14px; }
.key-input-group { margin-bottom: 18px; }
.key-input-wrapper { display: flex; gap: 8px; }
.key-input-wrapper input { flex: 1; }
.key-toggle {
  background: var(--card); border: 1.5px solid var(--line-strong);
  border-radius: var(--r-s); padding: 0 14px; font-size: 13px; font-weight: 700;
  color: var(--ink-soft); cursor: pointer;
}
.key-toggle:hover { border-color: var(--clay); color: var(--clay-deep); }
.key-status { font-size: 12px; color: var(--muted); margin-top: 6px; }
.key-status.saved { color: var(--sage-deep); }
.key-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.key-info { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 16px; }
.key-info summary { font-size: 14px; font-weight: 700; color: var(--ink-soft); cursor: pointer; }
.key-info-content { margin-top: 12px; font-size: 13.5px; color: var(--muted); display: flex; flex-direction: column; gap: 7px; }
.key-info-content code { background: var(--paper-2); padding: 2px 6px; border-radius: 5px; font-size: 12.5px; color: var(--clay-deep); }

/* ============ APP SHELL ============ */
#app-screen.active { display: flex; flex-direction: column; min-height: 100vh; }
.app-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  padding: 16px clamp(16px, 4vw, 36px);
  background: rgba(251,246,236,.86);
  backdrop-filter: blur(8px);
  border-bottom: 1.5px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.header-left { display: flex; align-items: center; gap: 13px; }
.brand-glyph {
  width: 40px; height: 40px; flex: none;
  border-radius: 11px;
  background: var(--clay);
  box-shadow: 0 2px 0 var(--clay-deep), var(--shadow-s);
  display: grid; place-items: center;
  color: #fff;
}
.app-title { font-size: 20px; }
.header-right { display: flex; align-items: center; gap: 9px; }

.app-main { flex: 1; width: 100%; max-width: var(--maxw); margin: 0 auto; padding: clamp(18px, 3vw, 30px) clamp(16px, 4vw, 36px) 60px; }

/* ============ STUDIO LAYOUT ============ */
.studio { display: grid; grid-template-columns: 372px 1fr; gap: 26px; align-items: start; }
.studio > * { min-width: 0; } /* COR-026: let the 1fr board shrink; inner scrollers handle overflow */

/* --- briefing panel --- */
.panel {
  background: var(--card-raised);
  border: 1.5px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  padding: 24px 22px;
  position: relative;
}
.brief-panel { position: sticky; top: 88px; }
.brief-panel::before {
  content: "";
  position: absolute; top: -12px; right: 22px;
  width: 78px; height: 24px;
  transform: rotate(3deg);
  background: repeating-linear-gradient(-45deg, rgba(111,138,106,.5) 0 7px, rgba(111,138,106,.32) 7px 14px);
  border-radius: 3px; opacity: .75; box-shadow: var(--shadow-s);
}
.panel-title { font-size: 19px; margin-bottom: 4px; }
.panel-sub { font-size: 13px; color: var(--muted); margin-bottom: 18px; }

.field { margin-bottom: 17px; }
.field > label { display: block; font-size: 12.5px; font-weight: 700; color: var(--ink-soft); margin-bottom: 7px; }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 500; }
textarea.field-input { resize: vertical; min-height: 78px; line-height: 1.5; }
select.field-input { appearance: none; -webkit-appearance: none; cursor: pointer;
  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='%238a7f6e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 13px center; padding-right: 38px;
}

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font-family: var(--sans);
  font-size: 13px; font-weight: 600;
  padding: 8px 13px;
  border-radius: var(--r-pill);
  border: 1.5px solid var(--line-strong);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .14s ease;
  user-select: none;
}
.chip:hover { border-color: var(--clay); color: var(--clay-deep); }
.chip.active {
  background: var(--clay);
  border-color: var(--clay);
  color: #fff;
  box-shadow: var(--shadow-s);
}
.chip.sage.active { background: var(--sage); border-color: var(--sage); }
.weekday-chips { display: none; }
.weekday-chips.show { display: flex; }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.model-row { display: flex; align-items: center; gap: 9px; margin-top: 4px; }
.model-row label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
#model-select { flex: 1; }
.key-link { font-size: 12px; color: var(--clay-deep); font-weight: 700; text-decoration: none; white-space: nowrap; }
.key-link:hover { text-decoration: underline; }

.generate-btn { width: 100%; margin-top: 8px; padding: 15px; font-size: 16px; }
.generate-btn .btn-loading { display: none; }

/* --- board --- */
.board {
  background: var(--card-raised);
  border: 1.5px solid var(--line);
  border-radius: var(--r-l);
  box-shadow: var(--shadow);
  min-height: 560px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.board-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 20px;
  border-bottom: 1.5px solid var(--line);
  background: var(--card);
}
.board-title-wrap { display: flex; flex-direction: column; gap: 2px; margin-right: auto; }
.board-month { font-size: 18px; font-family: var(--serif); }
.board-meta { font-size: 12.5px; color: var(--muted); }
.tabs { display: flex; gap: 4px; background: var(--paper-2); padding: 4px; border-radius: var(--r-pill); }
.tab {
  font-size: 13px; font-weight: 700; color: var(--muted);
  padding: 7px 15px; border: none; background: transparent; border-radius: var(--r-pill);
  cursor: pointer; transition: all .14s;
}
.tab:hover:not(:disabled) { color: var(--ink); }
.tab.active { background: var(--card-raised); color: var(--clay-deep); box-shadow: var(--shadow-s); }
.tab:disabled { opacity: .4; cursor: not-allowed; }
.board-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.board-actions .btn-secondary, .board-actions .btn-primary { padding: 9px 15px; font-size: 13px; }

.board-body { flex: 1; padding: 20px; position: relative; }

/* empty + loading states */
.state-empty, .state-loading {
  min-height: 480px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 30px; gap: 14px;
}
.state-empty .empty-art { width: 132px; height: 132px; opacity: .9; }
.state-empty h3 { font-size: 21px; }
.state-empty p { color: var(--muted); max-width: 420px; font-size: 14.5px; }
.spinner {
  width: 46px; height: 46px; border-radius: 50%;
  border: 4px solid var(--line-strong); border-top-color: var(--clay);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-step { color: var(--ink-soft); font-weight: 600; font-size: 15px; }
.loading-sub { color: var(--muted); font-size: 13px; }

/* warm-toned scrollbars for horizontally-scrollable panels (grid, table) —
   default gray system scrollbars read as a generic/cold UI accent on warm paper */
.cal-grid-wrap, .table-wrap {
  scrollbar-color: var(--line-strong) transparent;
}
.cal-grid-wrap::-webkit-scrollbar, .table-wrap::-webkit-scrollbar { height: 9px; }
.cal-grid-wrap::-webkit-scrollbar-track, .table-wrap::-webkit-scrollbar-track { background: transparent; }
.cal-grid-wrap::-webkit-scrollbar-thumb, .table-wrap::-webkit-scrollbar-thumb {
  background: var(--line-strong); border-radius: var(--r-pill); border: 2px solid var(--card-raised);
}
.cal-grid-wrap::-webkit-scrollbar-thumb:hover, .table-wrap::-webkit-scrollbar-thumb:hover { background: var(--clay-soft); }

/* horizontal scroll-shadow affordance — a soft edge vignette that only appears
   while there is more content to reveal in that direction (pure CSS, via the
   local/scroll background-attachment trick), so narrow/mobile viewports get a
   tactile hint that the grid/table pans sideways instead of a hard, silent clip. */
.cal-grid-wrap, .table-wrap {
  background-color: var(--card-raised);
  background-repeat: no-repeat;
  background-image:
    linear-gradient(to right, var(--card-raised) 40%, rgba(255,253,248,0)),
    linear-gradient(to left, var(--card-raised) 40%, rgba(255,253,248,0)),
    radial-gradient(farthest-side at 0% 50%, rgba(78,58,30,.2), rgba(78,58,30,0)),
    radial-gradient(farthest-side at 100% 50%, rgba(78,58,30,.2), rgba(78,58,30,0));
  background-position: left, right, left, right;
  background-size: 32px 100%, 32px 100%, 10px 90%, 10px 90%;
  background-attachment: local, local, scroll, scroll;
}

/* ============ CALENDAR GRID ============ */
.cal-grid-wrap { overflow-x: auto; padding-bottom: 4px; }
.cal-grid { min-width: 680px; }
.cal-weekhead { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 8px; }
.cal-weekhead span {
  text-align: center; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); padding: 4px 0;
}
.cal-weeks { display: flex; flex-direction: column; gap: 8px; }
.cal-week { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; }
.cal-cell {
  background: var(--card);
  border: 1.5px solid var(--line);
  border-radius: 12px;
  min-height: 104px;
  padding: 7px 7px 8px;
  display: flex; flex-direction: column; gap: 5px;
}
.cal-cell.blank { background: transparent; border: 1.5px dashed var(--line); opacity: .5; }
.cal-cell.has-post { border-color: var(--line-strong); box-shadow: var(--shadow-s); }
.cal-cell.today { outline: 2px solid var(--clay); outline-offset: -1px; }
.cell-daynum {
  width: 25px; height: 25px; flex: none;
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 800; color: var(--ink-soft);
  border-radius: 50%;
}
.cal-cell.has-post .cell-daynum { background: var(--clay-wash); color: var(--clay-deep); }
.cell-post {
  text-align: left; width: 100%;
  background: var(--card-raised);
  border: 1.5px solid var(--line);
  border-left-width: 4px;
  border-radius: 8px;
  padding: 6px 8px;
  cursor: pointer;
  transition: transform .1s, box-shadow .12s, background .12s;
  font-family: var(--sans);
}
.cell-post:hover { transform: translateY(-1px); box-shadow: var(--shadow-s); background: var(--card); }
.cell-post .cp-format { font-size: 9.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); display: block; }
.cell-post .cp-title { font-size: 11.5px; font-weight: 700; color: var(--ink); line-height: 1.25; display: block; margin-top: 1px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* pillar legend */
.pillar-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-bottom: 16px; padding: 12px 14px; background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r); }
.pillar-legend .pl-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); }
.pl-dot { width: 11px; height: 11px; border-radius: 50%; flex: none; }

/* ============ TABLE ============ */
.table-wrap { overflow-x: auto; }
table.cal-table { width: 100%; border-collapse: collapse; min-width: 760px; font-size: 13px; }
.cal-table thead th {
  text-align: left; font-family: var(--sans); font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); padding: 10px 10px; border-bottom: 2px solid var(--line-strong); white-space: nowrap;
}
.cal-table tbody td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink-soft); }
.cal-table tbody tr:hover { background: var(--card); }
.cal-table .td-date { white-space: nowrap; font-weight: 700; color: var(--ink); }
.cal-table .td-title { font-weight: 700; color: var(--ink); }
.cal-table .badge-fmt { display: inline-block; font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em; padding: 3px 8px; border-radius: var(--r-pill); background: var(--paper-2); color: var(--ink-soft); white-space: nowrap; }
.cal-table .td-pillar { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.cal-table .t-actions { display: flex; gap: 4px; }
.icon-btn-sm {
  width: 28px; height: 28px; display: grid; place-items: center; border-radius: 7px;
  border: 1.5px solid var(--line); background: var(--card-raised); color: var(--muted); cursor: pointer; transition: all .13s;
}
.icon-btn-sm:hover { border-color: var(--clay); color: var(--clay-deep); }
.icon-btn-sm:disabled { opacity: .4; cursor: not-allowed; }

/* ============ EXPORT TAB ============ */
.export-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.export-card {
  background: var(--card); border: 1.5px solid var(--line); border-radius: var(--r); padding: 22px 20px;
  display: flex; flex-direction: column; gap: 10px;
}
.export-card .ec-icon { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; color: #fff; }
.export-card.csv .ec-icon { background: var(--sage); }
.export-card.ics .ec-icon { background: var(--clay); }
.export-card h4 { font-size: 17px; }
.export-card p { font-size: 13.5px; color: var(--muted); flex: 1; }
.export-card .btn-primary { align-self: flex-start; }
.export-card.csv .btn-primary { background: var(--sage); box-shadow: 0 2px 0 var(--sage-deep), var(--shadow-s); }
.export-card.csv .btn-primary:hover { box-shadow: 0 4px 0 var(--sage-deep), var(--shadow); }
.export-note { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); background: var(--clay-wash); border: 1px solid var(--clay-soft); border-radius: var(--r-s); padding: 12px 14px; }

/* ============ POST DETAIL MODAL ============ */
.detail-overlay {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(44,39,31,.4);
  display: none; align-items: center; justify-content: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.detail-overlay.show { display: flex; }
.detail-card {
  background: var(--card-raised); border: 1.5px solid var(--line); border-radius: var(--r-l);
  box-shadow: var(--shadow-lift); width: 100%; max-width: 540px; max-height: 88vh; overflow-y: auto; padding: 26px 26px 24px;
}
.detail-head { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; margin-bottom: 14px; }
.detail-head .dh-date { font-size: 12.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--clay-deep); }
.detail-head h3 { font-size: 22px; margin-top: 5px; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 16px; }
.detail-block { margin-bottom: 15px; }
.detail-block .db-label { font-size: 11px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.detail-block .db-text { font-size: 14.5px; color: var(--ink-soft); line-height: 1.55; white-space: pre-wrap; }
.detail-hashtags { color: var(--sage-deep); font-weight: 600; }
.detail-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }

/* ============ KEY MODAL ============ */
.modal { position: fixed; inset: 0; z-index: 70; display: none; align-items: center; justify-content: center; padding: 20px; }
.modal[style*="flex"] { display: flex; }
.modal-overlay { position: absolute; inset: 0; background: rgba(44,39,31,.42); backdrop-filter: blur(3px); }
.modal-content {
  position: relative; background: var(--card-raised); border: 1.5px solid var(--line); border-radius: var(--r-l);
  box-shadow: var(--shadow-lift); width: 100%; max-width: 480px; padding: 26px;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-header h3 { font-size: 20px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; }
.modal-actions .btn-primary { flex: 1; }

/* ============ TOAST ============ */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(140%);
  background: var(--ink); color: #fff8ef; font-size: 14px; font-weight: 600;
  padding: 13px 22px; border-radius: var(--r-pill); box-shadow: var(--shadow-lift);
  z-index: 90; transition: transform .3s cubic-bezier(.2,.9,.3,1.2); max-width: 90vw; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--clay-deep); }

/* ============ FOOTER ============ */
/* extra bottom clearance so the fixed feedback button (bottom:24px/right:24px)
   never sits on top of the last footer link at rest */
.app-footer { text-align: center; padding: 30px 20px 84px; border-top: 1.5px solid var(--line); color: var(--muted); font-size: 13px; }
.app-footer strong { color: var(--clay-deep); }
.footer-links { margin-top: 6px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--clay-deep); text-decoration: underline; }
.footer-sep { margin: 0 8px; opacity: .5; }

/* ============ ACCESSIBILITY ============ */
:focus-visible { outline: 3px solid var(--clay); outline-offset: 2px; border-radius: 4px; }
.chip:focus-visible, .tab:focus-visible { outline-offset: 1px; }

/* ============ RESPONSIVE ============ */
@media (max-width: 940px) {
  .studio { grid-template-columns: 1fr; }
  .brief-panel { position: static; }
  .brief-panel::before { display: none; }
}
@media (max-width: 560px) {
  .gate-container, .key-container { padding: 32px 22px; }
  .app-main { padding-left: 14px; padding-right: 14px; }
  .board-bar { padding: 14px; }
  .board-title-wrap { width: 100%; margin-right: 0; }
  .tabs { width: 100%; }
  .tab { flex: 1; text-align: center; }
  .board-actions { width: 100%; }
  .board-actions .btn-secondary, .board-actions .btn-primary { flex: 1; }
  .export-grid { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
  .app-title { font-size: 17px; }
}

@media print {
  .app-header, .brief-panel, .board-bar, .app-footer, .toast, #feedback-btn, #feedback-modal { display: none !important; }
  body::before, body::after { display: none; }
  .board { box-shadow: none; border: none; }
}
