/*
 * Calm dark palette: deep slate (not purple-black) + a teal/terracotta duo
 * instead of the previous purple/hot-pink. Every color used at partial
 * opacity anywhere in this file goes through an -rgb triple so there is one
 * place to retheme from (token-driven, per the design-system convention).
 */
:root {
  --bg-rgb: 14, 20, 23;
  --bg: rgb(var(--bg-rgb));
  --bg-2: #131a1d;
  --card: #192124;
  --card-2: #212a2e;
  --line: #2a3437;
  --text: #eef3f2;
  --muted: #9fb0ae;
  --dim: #6c7c7a;

  --accent-rgb: 79, 189, 174;    /* teal - primary */
  --accent2-rgb: 201, 138, 82;   /* terracotta - secondary */
  --ok-rgb: 111, 199, 160;       /* sage green */
  --warn-rgb: 227, 179, 74;      /* amber */
  --err-rgb: 226, 119, 107;      /* muted coral */
  --info-rgb: 143, 168, 217;     /* dusty periwinkle - third content-type color */

  --accent: rgb(var(--accent-rgb));
  --accent-2: rgb(var(--accent2-rgb));
  --ok: rgb(var(--ok-rgb));
  --warn: rgb(var(--warn-rgb));
  --err: rgb(var(--err-rgb));
  --info: rgb(var(--info-rgb));

  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Heebo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 16px;
  line-height: 1.6;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  background-image:
    radial-gradient(1000px 500px at 100% -10%, rgba(var(--accent-rgb), .14), transparent 60%),
    radial-gradient(800px 400px at -10% 10%, rgba(var(--accent2-rgb), .10), transparent 60%);
  background-attachment: fixed;
}

h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.3; }
p { margin: 0 0 .8em; }
a { color: var(--accent); }

/* ---------- top bar ---------- */

#topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 10px) 14px 10px;
  background: rgba(var(--bg-rgb), .82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

#topTitle {
  flex: 1;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-btn {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  padding: 0;
}
.icon-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn[hidden] { visibility: hidden; display: grid; }
.icon-btn:active { background: var(--card-2); }

/* ---------- layout ---------- */

#app {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 14px calc(var(--safe-bottom) + 90px);
}

.screen { animation: rise .25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hero { padding: 8px 2px 20px; }
.hero h2 { font-size: 1.7rem; font-weight: 900; letter-spacing: -.02em; }
.hero .sub { color: var(--muted); font-size: .95rem; margin-top: 4px; }

.brand {
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- cards ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card.tight { padding: 13px 14px; }

.tap-card {
  display: block;
  width: 100%;
  text-align: inherit;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.tap-card:active { transform: scale(.99); background: var(--card-2); }

.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

.avatar {
  width: 44px; height: 44px;
  flex: 0 0 44px;
  border-radius: 13px;
  display: grid; place-items: center;
  font-weight: 900; font-size: 1.05rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.title-line { font-weight: 700; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.meta { color: var(--muted); font-size: .84rem; }
.dim { color: var(--dim); }

.chevron { color: var(--dim); flex: 0 0 auto; }
.chevron svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 18px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, opacity .12s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: rgba(var(--err-rgb), .35); background: rgba(var(--err-rgb), .08); }
.btn.block { width: 100%; }
.btn.sm { padding: 9px 13px; font-size: .88rem; border-radius: 11px; }

.fab-row { position: sticky; bottom: calc(var(--safe-bottom) + 14px); margin-top: 18px; z-index: 20; }

/* ---------- forms ---------- */

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: .88rem; font-weight: 500; color: var(--muted); margin-bottom: 6px; }

input[type=text], input[type=password], input[type=url], input[type=number], textarea, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  font: inherit;
  font-size: 16px; /* keeps iOS from zooming on focus */
}
textarea { min-height: 110px; resize: vertical; line-height: 1.6; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
input::placeholder, textarea::placeholder { color: var(--dim); }

.hint { font-size: .8rem; color: var(--dim); margin-top: 5px; }

.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  font-size: 1.3rem; font-weight: 700;
  cursor: pointer;
}
.stepper button:active { background: var(--accent); }
.stepper .value { min-width: 42px; text-align: center; font-size: 1.25rem; font-weight: 900; }

.type-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}
.type-row:last-child { border-bottom: 0; }
.type-row .label { font-weight: 700; }
.type-row .label small { display: block; font-weight: 400; color: var(--dim); font-size: .78rem; }

/* ---------- pills & badges ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .76rem; font-weight: 700;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--muted);
  white-space: nowrap;
}
/* reel/post/story are the three content-type colors; ok/warn/err are status */
.pill.reel { color: var(--accent); border-color: rgba(var(--accent-rgb), .4); background: rgba(var(--accent-rgb), .14); }
.pill.post { color: var(--accent-2); border-color: rgba(var(--accent2-rgb), .4); background: rgba(var(--accent2-rgb), .14); }
.pill.story { color: var(--info); border-color: rgba(var(--info-rgb), .4); background: rgba(var(--info-rgb), .14); }
.pill.ok { color: var(--ok); border-color: rgba(var(--ok-rgb), .4); background: rgba(var(--ok-rgb), .14); }
.pill.warn { color: var(--warn); border-color: rgba(var(--warn-rgb), .4); background: rgba(var(--warn-rgb), .14); }
.pill.err { color: var(--err); border-color: rgba(var(--err-rgb), .4); background: rgba(var(--err-rgb), .14); }

/* ---------- progress ---------- */

.progress { height: 7px; border-radius: 999px; background: var(--bg-2); overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .4s ease; }

.spinner {
  width: 17px; height: 17px;
  border: 2.5px solid rgba(255, 255, 255, .22);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- item detail ---------- */

.section { margin-bottom: 18px; }
.section > h4 {
  font-size: .8rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
  font-weight: 700;
}

.beat {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.beat:last-child { border-bottom: 0; }
.beat .t { font-weight: 900; color: var(--accent); font-size: .82rem; padding-top: 2px; }
.beat .b { min-width: 0; }
.beat .b b { color: var(--muted); font-weight: 500; font-size: .78rem; display: block; margin-top: 6px; }
.beat .b .spoken { font-weight: 500; }
.beat .b:first-child > :first-child { margin-top: 0; }

ul.clean { margin: 0; padding: 0 18px 0 0; }
ul.clean li { margin-bottom: 5px; }

.copybox {
  position: relative;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: .95rem;
}

.hooks { display: grid; gap: 8px; }
.hook {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-right: 3px solid var(--accent);
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 500;
}

.comment {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.comment .who { font-size: .78rem; color: var(--dim); margin-bottom: 3px; }

/* ---------- misc ---------- */

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .big { font-size: 2.6rem; margin-bottom: 10px; }

.divider { height: 1px; background: var(--line); margin: 16px 0; }

.week-head {
  display: flex; align-items: center; gap: 10px;
  margin: 22px 0 10px;
  font-weight: 900;
  color: var(--muted);
  font-size: .9rem;
}
.week-head::after { content: ''; flex: 1; height: 1px; background: var(--line); }

#toast {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 22px);
  left: 50%;
  transform: translate(-50%, 24px);
  background: var(--card-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 100;
  max-width: 90vw;
  text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { border-color: rgba(var(--err-rgb), .5); color: #ffdcd6; }

.center-screen {
  min-height: 78dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (min-width: 620px) {
  .cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .cols-2 .card { margin-bottom: 0; }
}
