:root {
  --paper: #EFE7D8;
  --paper-raised: #F7F2E6;
  --ink: #1F2A3C;
  --ink-soft: #4B5768;
  --rule: #D6C9AC;
  --brass: #A9793B;
  --brass-dark: #8A5F28;
  --live: #3F6C51;
  --submitted: #B8863B;
  --blocked: #9B3B34;
  --not-started: #9A9182;
  --radius: 3px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='3' stitchTiles='stitch'/><feColorMatrix type='matrix' values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 0.05 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  color: var(--ink);
  font-family: 'Inter', sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Libre Baskerville', serif; font-weight: 700; margin: 0; }

.hidden { display: none !important; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  border-bottom: 1px solid var(--rule);
}
.brand {
  font-family: 'Libre Baskerville', serif;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 0.02em;
}
.auth-status { font-family: 'Inter', sans-serif; font-size: 13px; color: var(--ink-soft); cursor: pointer; }

/* --- Auth --- */
.auth-wrap { display: flex; justify-content: center; padding: 60px 20px; }
.auth-card {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 48px;
  max-width: 440px;
  width: 100%;
}
.auth-card h1 { font-size: 28px; line-height: 1.25; margin-bottom: 12px; }
.sub { color: var(--ink-soft); font-size: 15px; margin-bottom: 28px; line-height: 1.5; }
.tabs { display: flex; border-bottom: 1px solid var(--rule); margin-bottom: 24px; }
.tab {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  background: none; border: none; cursor: pointer;
  padding: 10px 4px; margin-right: 24px;
  color: var(--ink-soft);
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--ink); border-bottom-color: var(--brass); }
.auth-form { display: flex; flex-direction: column; gap: 16px; }
label { font-size: 13px; color: var(--ink-soft); display: flex; flex-direction: column; gap: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number] {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: #FBF8F1;
  color: var(--ink);
  box-shadow: inset 0 1px 2px rgba(31,42,60,0.05);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus {
  outline: none;
  border-color: var(--brass);
  box-shadow: 0 0 0 3px rgba(169,121,59,0.15);
}
.checkbox { flex-direction: row; align-items: center; gap: 8px; }
.checkbox input { width: auto; }

button { font-family: inherit; cursor: pointer; }
.btn-primary {
  background: var(--ink);
  color: var(--paper-raised);
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
}
.btn-primary:hover { background: var(--brass-dark); }
.btn-ghost {
  background: none;
  border: 1px solid var(--rule);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--ink-soft);
}
.btn-ghost:hover { border-color: var(--brass); color: var(--ink); }
.form-error { color: var(--blocked); font-size: 13px; min-height: 16px; }

/* --- Dashboard / shelf --- */
main { padding: 40px; max-width: 1100px; margin: 0 auto; }
.billing-bar {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--paper-raised); border: 1px solid var(--brass);
  border-radius: var(--radius); padding: 14px 20px; margin-bottom: 24px;
  font-size: 14px;
}
.billing-bar .plans { display: flex; gap: 10px; align-items: center; }
.billing-bar button {
  background: var(--brass); color: #fff; border: none;
  padding: 8px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 600;
}
.billing-bar .btn-ghost-small {
  background: none; color: var(--ink-soft); border: 1px solid var(--rule);
  padding: 7px 14px; font-weight: 500;
}
.billing-bar #promoInput {
  padding: 7px 10px; font-size: 13px; border-radius: var(--radius);
  border: 1px solid var(--rule); background: #FBF8F1; width: 120px;
}
.shelf-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 28px; }
.shelf-header h1 { font-size: 26px; }

.shelf {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 3px;
  padding-bottom: 16px;
  border-bottom: 6px solid var(--brass-dark);
}
.spine {
  width: 74px;
  min-height: 220px;
  background: var(--ink);
  border-radius: 2px 2px 0 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 8px;
  cursor: pointer;
  position: relative;
  transition: transform 0.15s ease;
}
.spine:hover { transform: translateY(-6px); }
.spine-title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: 'Libre Baskerville', serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--paper-raised);
  line-height: 1.4;
  max-height: 160px;
  overflow: hidden;
}
.spine-progress {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: 'Inter', sans-serif;
  font-size: 10px;
  color: var(--paper);
  opacity: 0.7;
}
.empty-shelf {
  font-family: 'Inter', sans-serif;
  color: var(--ink-soft);
  font-size: 14px;
  padding: 40px 0;
}

/* --- Title detail --- */
.title-head { margin-bottom: 8px; }
.title-head h1 { font-size: 30px; }
.title-meta { color: var(--ink-soft); font-size: 14px; margin-top: 6px; }
.ku-flag {
  display: inline-block;
  background: var(--brass);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

.section { margin-top: 36px; }
.section-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.section-head h3 { font-size: 17px; }

.format-block {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}
.format-block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.format-type { font-family: 'Libre Baskerville', serif; font-weight: 700; font-size: 17px; text-transform: capitalize; }
.stage-pill {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 10px;
  background: var(--rule);
  color: var(--ink);
  text-transform: capitalize;
}
.format-sub { font-size: 13px; color: var(--ink-soft); margin-bottom: 14px; }

.platform-grid { display: flex; flex-direction: column; gap: 6px; }
.platform-row {
  display: grid;
  grid-template-columns: 1fr 110px 1fr;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-size: 13px;
}
.platform-row:nth-child(odd) { background: rgba(0,0,0,0.02); }
.platform-name { font-weight: 500; }
.status-select {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1px solid var(--rule);
  background: #fff;
}
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.status-not_started .status-dot { background: var(--not-started); }
.status-submitted .status-dot { background: var(--submitted); }
.status-live .status-dot { background: var(--live); }
.status-rejected .status-dot, .status-blocked .status-dot { background: var(--blocked); }
.reason-input {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  width: 100%;
}

.vendor-list, .cover-list { display: flex; flex-wrap: wrap; gap: 8px; }
.vendor-chip {
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 6px 14px;
  font-size: 13px;
}
.vendor-chip .vtype { color: var(--ink-soft); font-family: 'Inter', sans-serif; font-size: 11px; margin-left: 6px; }

.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 10px; }
.inline-form input, .inline-form select {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--rule);
  border-radius: 5px;
  background: #FBF8F1;
  color: var(--ink);
}
.inline-form button {
  background: var(--brass);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
}

/* --- Modal --- */
.modal {
  position: fixed; inset: 0;
  background: rgba(31,42,60,0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-card {
  background: var(--paper-raised);
  border-radius: var(--radius);
  padding: 32px;
  max-width: 420px;
  width: 100%;
}
.modal-card h2 { font-size: 20px; margin-bottom: 20px; }
.modal-card form { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; }
.row label { flex: 1; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }

@media (max-width: 640px) {
  main { padding: 24px 16px; }
  .platform-row { grid-template-columns: 1fr; }
  .modal { padding: 12px; }
  .modal-card { padding: 22px; max-width: 100%; }
  .row { flex-direction: column; gap: 14px; }
  .spine { width: 60px; min-height: 180px; }
}
