:root {
  --gold: #C9A84C;
  --gold-dark: #A88A35;
  --ink: #2D2D2D;
  --ink-soft: #5E5A52;
  --cream: #F7F5F0;
  --card: #FFFFFF;
  --line: #E6E1D6;
  --green: #2E7D4F;
  --red: #B3261E;
  --blue: #1B3A6B;
  --gray: #A39E93;
  --radius: 12px;
  font-family: "Heebo", system-ui, sans-serif;
  color: var(--ink);
  background: var(--cream);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--cream); font-size: 16px; line-height: 1.5; }
h1, h2 { margin: 0; font-weight: 700; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.125rem; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* Buttons */
.btn { min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent; font-weight: 500; white-space: nowrap; }
.btn-primary { background: var(--gold); color: var(--ink); }
.btn-primary:hover { background: var(--gold-dark); }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover { border-color: var(--ink-soft); }
.btn-danger { background: transparent; color: var(--red); border-color: #E7C2BF; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: var(--card); }
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.link-btn { background: none; border: 0; color: var(--ink-soft); text-decoration: underline; min-height: 44px; }

/* Login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 28px 24px; display: grid; gap: 10px; }
.login-card h1 { margin-bottom: 8px; }

/* Board */
#board { max-width: 1400px; margin: 0 auto; padding: 16px; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; justify-content: space-between; }
.week-nav { display: flex; align-items: center; gap: 8px; }
#week-label { min-width: 150px; text-align: center; font-weight: 500; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 16px; padding: 0; margin: 14px 0; color: var(--ink-soft); font-size: .875rem; }
.legend li { display: flex; align-items: center; gap: 6px; }

.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.dot.scheduled { background: transparent; border: 2px solid var(--gold); }
.dot.publishing { background: var(--blue); animation: pulse 1.2s infinite; }
.dot.published { background: var(--green); }
.dot.failed { background: var(--red); }
@keyframes pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dot.publishing { animation: none; } }

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); min-height: 220px; padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.day.today { border-color: var(--gold); box-shadow: inset 0 3px 0 var(--gold); }
.day-head { font-weight: 700; font-size: .9375rem; }
.day-head small { font-weight: 400; color: var(--ink-soft); margin-inline-start: 4px; }
.day-empty { color: var(--gray); font-size: .875rem; }

.card { display: flex; gap: 8px; align-items: stretch; text-align: start; width: 100%; background: var(--cream); border: 1px solid var(--line); border-radius: 10px; padding: 6px; }
.card:hover { border-color: var(--gold); }
.card img { width: 44px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 6px; background: var(--line); flex: none; }
.card-body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.card-time { font-weight: 700; font-size: .875rem; }
.card-title { font-size: .875rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.card-nets { display: flex; flex-wrap: wrap; gap: 6px; font-size: .75rem; color: var(--ink-soft); }
.card-nets span { display: inline-flex; align-items: center; gap: 3px; }

.empty { text-align: center; padding: 32px 16px; color: var(--ink-soft); }
.foot { text-align: center; margin-top: 20px; }

/* Sheet */
.sheet { width: min(680px, 100vw); max-height: 100dvh; border: 0; border-radius: var(--radius); padding: 0; background: var(--card); color: var(--ink); }
.sheet::backdrop { background: rgba(45, 45, 45, .55); }
#post-form { padding: 16px 20px 20px; display: grid; gap: 14px; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; }
.banner { background: #E8EEF7; color: var(--blue); border-radius: 10px; padding: 10px 12px; font-weight: 500; }

.drop { display: grid; gap: 10px; place-items: center; border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px 12px; text-align: center; cursor: pointer; color: var(--ink-soft); }
.drop:hover { border-color: var(--gold); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }
.progress { width: 100%; max-width: 320px; height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .2s; }

fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
legend, label { font-weight: 500; }
.opt { font-weight: 400; color: var(--ink-soft); font-size: .875rem; }
.frames { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.frame { position: relative; padding: 0; border: 3px solid transparent; border-radius: 10px; overflow: hidden; background: var(--line); }
.frame img { width: 100%; aspect-ratio: 9 / 16; object-fit: cover; display: block; }
.frame[aria-pressed="true"] { border-color: var(--gold); }
.frame small { position: absolute; bottom: 4px; inset-inline-start: 4px; background: rgba(45,45,45,.75); color: #fff; padding: 0 5px; border-radius: 4px; font-size: .75rem; }

.field { display: grid; gap: 6px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field input, .field textarea, .login-card input { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, .login-card input:focus { border-color: var(--gold); outline: none; box-shadow: 0 0 0 3px rgba(201,168,76,.25); }
.field-error, .form-error { margin: 0; color: var(--red); font-size: .875rem; min-height: 0; }
.field-error:empty, .form-error:empty { display: none; }
.invalid input, .invalid textarea { border-color: var(--red); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 22px; font-weight: 400; cursor: pointer; }
.chip:has(input:checked) { border-color: var(--gold); background: #FBF6E7; }
.chip input { accent-color: var(--gold); width: 18px; height: 18px; margin: 0; }

.status-row { display: flex; gap: 14px; align-items: flex-start; }
.cover-lg { width: 96px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 10px; background: var(--line); flex: none; }
.targets { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; flex: 1; min-width: 0; }
.target { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; display: grid; gap: 4px; }
.target-head { display: flex; align-items: center; gap: 8px; font-weight: 500; flex-wrap: wrap; }
.target-head .state { color: var(--ink-soft); font-weight: 400; font-size: .875rem; }
.target a { color: var(--blue); font-size: .875rem; word-break: break-all; }
.target .err { color: var(--red); font-size: .875rem; overflow-wrap: anywhere; }
.target .btn { justify-self: start; min-height: 36px; }

.sheet-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }

/* Phone: list by day, full-screen sheet */
@media (max-width: 900px) {
  .week { grid-template-columns: 1fr; }
  .day { min-height: 0; }
  .day.no-posts { display: none; }
  .sheet { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; border-radius: 0; margin: 0; }
  #post-form { padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
  .frames { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .field-row { grid-template-columns: 1fr; }
  .topbar h1 { flex: 1 0 auto; }
  .week-nav { order: 3; width: 100%; justify-content: space-between; }
  #week-label { min-width: 0; flex: 1; }
}
