/* Styled after tedxpetalingstreet.com: black canvas, white type, TED red. */
:root {
  --bg: #000;
  --surface: #111;
  --surface-2: #1a1a1a;
  --line: #2e2e2e;
  --line-strong: #3f3f46;
  --text: #fff;
  --muted: #9ca3af;
  --dim: #8a8a8a;
  --red: #e62b1e;
  --red-fill: #c8231a; /* behind white text: 5.6:1 */
  --red-dark: #a21911;
  --red-deep: #480805;
  --radius: 6px;
  /* TED's brand face is Helvetica Neue; Noto Sans SC covers Chinese, as on tedxpetalingstreet.com. */
  --font: "Helvetica Neue", Helvetica, Arial, "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
}

.container { width: 100%; max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-top: 14px; padding-bottom: 14px;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--text); }
.brand-ted { font-weight: 900; font-size: 22px; letter-spacing: -0.5px; color: var(--red); }
.brand-ted sup { font-size: 0.7em; vertical-align: 0.45em; }
.brand-name { font-weight: 300; font-size: 22px; letter-spacing: -0.3px; }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 1.5px; text-transform: uppercase; margin-left: 4px; }
.nav { display: flex; gap: 4px; }
.nav a {
  color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500;
  padding: 8px 12px; border-radius: var(--radius);
}
.nav a:hover { color: var(--text); }
.nav a[aria-current="page"] { color: var(--text); box-shadow: inset 0 -2px 0 var(--red); border-radius: 0; }

/* Hero */
.hero { padding: 48px 0 28px; border-bottom: 1px solid var(--line); }
.eyebrow { color: var(--red); font-size: 15px; font-weight: 600; margin: 0 0 8px; }
.hero h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.1; margin: 0 0 12px; font-weight: 800; letter-spacing: -1px; }
.hero h1 em { font-style: normal; color: var(--red); }
.hero p { color: var(--muted); max-width: 640px; margin: 0; }

/* Layout */
.layout { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 32px; padding: 32px 0 64px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.sticky-col { position: sticky; top: 84px; }
@media (max-width: 900px) { .sticky-col { position: static; } }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 0 0 16px; }
.section-head h2 { margin: 0; font-size: 20px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.tag {
  display: inline-grid; place-items: center; width: 28px; height: 28px;
  background: var(--red-fill); color: #fff; font-weight: 800; font-size: 14px; border-radius: 4px;
}
.section-sub { color: var(--muted); font-size: 13px; margin: -8px 0 18px; }

/* Forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 16px; }
.card h3, .card .card-label { margin: 0 0 14px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 1.5px; font-weight: 600; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 520px) { .grid-2 { grid-template-columns: 1fr; } }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.grid-2 .field { margin-bottom: 0; }
.grid-2 + .field, .grid-2 + .grid-2 { margin-top: 14px; }
label { font-size: 13px; font-weight: 600; }
label .zh { color: var(--muted); font-weight: 400; margin-left: 4px; }
label .opt { color: var(--dim); font-weight: 400; font-size: 12px; margin-left: 4px; }
.hint { color: var(--dim); font-size: 12px; margin: 0; }
input, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 10px 12px; transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--dim); }
input:focus, textarea:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(230, 43, 30, .25); }
input.prefix-ep { padding-left: 42px; }
.ep-wrap { position: relative; }
.ep-wrap::before { content: "EP"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--red); font-weight: 700; font-size: 14px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: transparent; color: var(--text); text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.btn:hover { border-color: var(--text); }
.btn-primary { background: var(--red-fill); border-color: var(--red-fill); }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: transparent; }
.btn.is-done { background: #fff; color: #000; border-color: #fff; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* Credits summary on generator page */
.credits-summary { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; margin: 0; }
.credits-summary dt { color: var(--muted); }
.credits-summary dd { margin: 0; overflow-wrap: anywhere; }

/* Output posts */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tabs button {
  font: inherit; font-size: 13px; cursor: pointer; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: transparent; color: var(--muted);
}
.tabs button[aria-pressed="true"] { background: var(--text); color: #000; border-color: var(--text); font-weight: 600; }

.post { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; }
.post-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.post-title { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.post-num { color: var(--red); font-weight: 800; font-variant-numeric: tabular-nums; }
.post-name { font-weight: 600; }
.post-note { color: var(--dim); font-size: 12px; }
.post-meta { color: var(--dim); font-size: 12px; font-variant-numeric: tabular-nums; }
.post-body {
  margin: 0; padding: 16px; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: var(--font); font-size: 14px; line-height: 1.65; color: #e5e5e5;
  max-height: 420px; overflow: auto;
}
.post.is-empty .post-body { color: var(--dim); }

.warn { background: var(--red-deep); border: 1px solid var(--red-dark); color: #fecaca; border-radius: var(--radius); padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.warn[hidden] { display: none; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  background: #fff; color: #000; font-weight: 600; font-size: 14px;
  padding: 10px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Selects */
select {
  width: 100%; font: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 10px 12px;
}
select:focus { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(230, 43, 30, .25); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 640px) { .grid-3 { grid-template-columns: 1fr; } }
.grid-3 .field { margin-bottom: 0; }

/* DB status pill */
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.status[data-state="ok"]::before { background: #22c55e; }
.status[data-state="busy"]::before { background: #eab308; }
.status[data-state="err"]::before { background: var(--red); }
.status[data-state="err"] { color: #fecaca; }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar input[type="search"] { flex: 1 1 260px; width: auto; }
.toolbar select { width: auto; flex: 0 0 auto; }
.count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }

/* Episode table */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { position: sticky; top: 0; background: var(--surface-2); color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--surface); }
tbody tr:focus-visible { outline: 2px solid var(--red); outline-offset: -2px; }
tbody tr:last-child td { border-bottom: 0; }
td.ep { color: var(--red); font-weight: 700; white-space: nowrap; font-variant-numeric: tabular-nums; }
td.name { min-width: 260px; }
td.muted { color: var(--muted); }
.chip { display: inline-block; font-size: 12px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; margin: 0 4px 4px 0; }
.chip.main { border-color: var(--red-dark); color: #fff; background: var(--red-deep); }
.empty-row td { text-align: center; color: var(--muted); padding: 32px; cursor: default; }
@media (max-width: 760px) { .hide-sm { display: none; } }

/* Dialog */
.dialog { background: var(--surface); color: var(--text); border: 1px solid var(--line-strong); border-radius: 10px; padding: 0; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 32px); }
.dialog::backdrop { background: rgba(0, 0, 0, .7); }
.dialog-body { padding: 24px; }
.dialog h2 { margin: 0 0 16px; font-size: 20px; }
.dialog-foot { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.btn-danger { color: #fecaca; border-color: var(--red-dark); }
.btn-danger:hover { background: var(--red-deep); border-color: var(--red); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* Custom dropdown (assets/dropdown.js) */
.dd { position: relative; width: 100%; }
.dd.dd-inline { width: auto; flex: 0 0 auto; min-width: 200px; }
.dd-trigger {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 10px 12px; transition: border-color .15s, box-shadow .15s;
}
.dd-trigger:hover { border-color: var(--muted); }
.dd-trigger:focus-visible, .dd.is-open .dd-trigger { outline: none; border-color: var(--red); box-shadow: 0 0 0 3px rgba(230, 43, 30, .25); }
.dd-trigger.is-placeholder .dd-value { color: var(--dim); }
.dd-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.dd-caret { width: 12px; height: 12px; flex: 0 0 12px; color: var(--muted); transition: transform .15s; }
.dd.is-open .dd-caret { transform: rotate(180deg); color: var(--red); }
.dd-pop {
  position: absolute; z-index: 60; left: 0; right: 0; top: calc(100% + 6px); min-width: 220px;
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, .6); padding: 6px;
}
.dd-pop.dd-up { top: auto; bottom: calc(100% + 6px); }
.dd-search { margin-bottom: 6px; padding: 8px 10px; font-size: 14px; }
.dd-list { list-style: none; margin: 0; padding: 0; max-height: 280px; overflow-y: auto; overscroll-behavior: contain; }
.dd-option {
  padding: 9px 12px 9px 30px; border-radius: 4px; cursor: pointer; font-size: 14px; position: relative;
  overflow-wrap: anywhere;
}
.dd-option.is-active { background: var(--line); }
.dd-option[aria-selected="true"] { color: var(--text); font-weight: 600; }
.dd-option[aria-selected="true"]::before {
  content: ""; position: absolute; left: 11px; top: 50%; width: 8px; height: 8px; margin-top: -4px;
  border-radius: 50%; background: var(--red);
}
.dd-option.dd-placeholder { color: var(--muted); }
.dd-option[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.dd-option[hidden] { display: none; }

/* Themes page */
.theme-section { padding-top: 32px; }
.theme-section > .warn { margin-bottom: 16px; }
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
@media (max-width: 400px) { .theme-grid { grid-template-columns: 1fr; } }
.theme-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; cursor: pointer; display: flex; flex-direction: column; gap: 12px;
  transition: border-color .15s;
}
.theme-card:hover { border-color: var(--line-strong); }
.theme-card:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
.theme-card.is-suggested { border-style: dashed; }
.theme-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.theme-name { margin: 0; font-size: 18px; font-weight: 700; }
.theme-zh { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.theme-count { text-align: right; line-height: 1; }
.theme-count strong { display: block; font-size: 32px; font-weight: 800; color: var(--red); font-variant-numeric: tabular-nums; }
.theme-count span { font-size: 12px; color: var(--muted); }
.theme-bar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; }
.theme-bar span { display: block; height: 100%; background: var(--red); }
.theme-desc { margin: 0; color: #d4d4d4; font-size: 14px; }
.theme-origin { margin: 0; font-size: 12px; color: var(--muted); }
.theme-trigger { margin: 0; font-size: 13px; color: #fff; border-left: 2px solid var(--red); padding-left: 10px; }
.theme-tagged { margin: auto 0 0; font-size: 13px; color: var(--muted); }
.theme-tagged a, .theme-link { color: var(--text); text-decoration: none; border-bottom: 1px solid var(--red); align-self: flex-start; font-size: 13px; font-weight: 600; }
.theme-link { margin-top: auto; }
.theme-subs { display: flex; flex-wrap: wrap; }
.chip-cloud { display: flex; flex-wrap: wrap; }
a.chip { text-decoration: none; }
a.chip:hover { color: var(--text); border-color: var(--text); }
[hidden] { display: none !important; }

footer { border-top: 1px solid var(--line); color: var(--dim); font-size: 12px; padding: 20px 0 32px; }
footer a { color: var(--muted); }

@media (max-width: 640px) {
  .brand-sub { display: none; }
  .brand-name, .brand-ted { font-size: 18px; }
  .hero { padding-top: 32px; }
}
