:root {
  --cream: #fbf3e7;
  --cream-deep: #f3e6d3;
  --paper: #fffdf9;
  --ink: #2c2117;
  --ink-soft: #6b5d4d;
  --coral: #e8664a;
  --coral-deep: #d14d31;
  --teal: #3f8f88;
  --teal-deep: #2d6b65;
  --gold: #e0a232;
  --line: #e4d5bf;
  --radius-lg: 24px;
  --radius-md: 14px;
  --shadow: 0 16px 32px -18px rgba(44, 33, 23, 0.28);
}
:root[data-theme="dark"] {
  --cream: #1b140f; --cream-deep: #201811; --paper: #221a13;
  --ink: #f4e9da; --ink-soft: #cbb9a3; --line: #3a2d20;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --cream: #1b140f; --cream-deep: #201811; --paper: #221a13;
    --ink: #f4e9da; --ink-soft: #cbb9a3; --line: #3a2d20;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.7;
}
h1, h2, h3 { font-family: "Zen Maru Gothic", "Noto Sans JP", sans-serif; font-weight: 900; margin: 0; }
a { color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 22px; border-radius: 999px; font-weight: 700; font-size: 0.92rem;
  border: none; cursor: pointer; text-decoration: none; transition: transform .15s ease;
}
.btn-primary { background: var(--coral); color: #fff8f0; }
.btn-primary:hover { transform: translateY(-1px); }
.btn-ghost { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }

input[type=email], input[type=password], input[type=text] {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--ink);
  font-size: 0.95rem;
  font-family: inherit;
}
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--gold); outline-offset: 2px;
}
label { display: block; font-size: 0.85rem; font-weight: 700; margin-bottom: 6px; color: var(--ink-soft); }

/* ---- login page ---- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 40px 32px;
}
.login-card .logo {
  font-family: "Zen Maru Gothic", sans-serif;
  font-weight: 900;
  font-size: 1.5rem;
  color: var(--coral-deep);
  text-align: center;
  display: block;
  margin-bottom: 8px;
  text-decoration: none;
}
.login-card .sub { text-align: center; color: var(--ink-soft); font-size: 0.88rem; margin-bottom: 28px; }
.field + .field { margin-top: 18px; }
.login-card .btn-primary { width: 100%; margin-top: 26px; }
.login-error {
  background: #fbe3dd; color: var(--coral-deep); border-radius: 10px;
  padding: 10px 14px; font-size: 0.85rem; margin-top: 18px; display: none;
}
.login-error.show { display: block; }
.back-link { display: block; text-align: center; margin-top: 22px; font-size: 0.85rem; color: var(--ink-soft); text-decoration: none; }
.back-link:hover { color: var(--coral-deep); }

/* ---- dashboard shell ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--paper);
  border-right: 1px solid var(--line);
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
}
.sidebar .logo { font-family: "Zen Maru Gothic", sans-serif; font-weight: 900; font-size: 1.4rem; color: var(--coral-deep); margin-bottom: 40px; display: block; text-decoration: none; }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex-grow: 1; }
.side-nav a, .side-nav .disabled {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 14px; border-radius: 12px; font-size: 0.9rem; font-weight: 700;
  text-decoration: none; color: var(--ink-soft);
}
.side-nav a.active { background: var(--cream-deep); color: var(--coral-deep); }
.side-nav a:hover:not(.active) { background: var(--cream-deep); }
.side-nav .disabled { color: var(--line); cursor: default; }
.side-nav .disabled .tag { margin-left: auto; font-size: 0.68rem; background: var(--cream-deep); color: var(--ink-soft); padding: 2px 8px; border-radius: 999px; }
.sidebar .logout { margin-top: auto; }

.main {
  flex-grow: 1;
  padding: 36px 40px;
  max-width: 980px;
}
.page-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 32px; flex-wrap: wrap; gap: 16px; }
.page-head h1 { font-size: 1.6rem; }
.page-head .plan-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--teal); color: #f4fbfa; font-size: 0.78rem; font-weight: 700;
  padding: 6px 14px; border-radius: 999px; margin-top: 8px;
}

.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin-bottom: 36px; }
.stat-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: 22px; box-shadow: var(--shadow);
}
.stat-card .label { font-size: 0.82rem; color: var(--ink-soft); font-weight: 700; margin-bottom: 8px; }
.stat-card .value { font-family: "Zen Maru Gothic", sans-serif; font-weight: 900; font-size: 2rem; color: var(--coral-deep); }
.stat-card .value small { font-size: 1rem; font-weight: 700; color: var(--ink-soft); margin-left: 4px; }

.panel {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: 26px 26px 8px; margin-bottom: 28px; box-shadow: var(--shadow);
}
.panel h2 { font-size: 1.05rem; margin-bottom: 18px; }
.list-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 0; border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: none; }
.list-row .platform-dot {
  width: 34px; height: 34px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--cream-deep); font-size: 0.95rem;
}
.list-row .content { flex-grow: 1; min-width: 0; }
.list-row .title { font-weight: 700; font-size: 0.92rem; margin-bottom: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row .meta { font-size: 0.78rem; color: var(--ink-soft); }
.chip {
  font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; flex-shrink: 0; white-space: nowrap;
}
.chip.published, .chip.auto_sent { background: #e3f1ee; color: var(--teal-deep); }
.chip.scheduled { background: #fdeecb; color: #9c6b0e; }
.chip.needs_review, .chip.pending_review { background: #fbe3dd; color: var(--coral-deep); }
.chip.escalated { background: #f0e2fb; color: #7a4bb0; }

.empty { color: var(--ink-soft); font-size: 0.88rem; padding: 20px 0; text-align: center; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex-direction: row; align-items: center;
    padding: 12px 14px; gap: 8px; overflow-x: auto;
    position: sticky; top: 0; z-index: 10;
  }
  .sidebar .logo { margin-bottom: 0; flex-shrink: 0; }
  .side-nav { flex-direction: row; flex-grow: 0; flex-shrink: 0; gap: 6px; }
  .side-nav a, .side-nav .disabled {
    flex-direction: column; gap: 2px; padding: 8px 12px;
    white-space: nowrap; font-size: 0.72rem; text-align: center;
  }
  .side-nav .disabled .tag { margin-left: 0; }
  .sidebar .logout { margin-top: 0; margin-left: 0; flex-shrink: 0; white-space: nowrap; }
  .main { padding: 24px 18px; }
  .stat-grid { grid-template-columns: 1fr; }
}
