/* Inter and JetBrains Mono, served from this site (SIL Open Font License, see fonts/). */
@font-face { font-family: 'Inter'; font-weight: 400; font-style: normal; font-display: swap; src: url('../fonts/inter-400.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 500; font-style: normal; font-display: swap; src: url('../fonts/inter-500.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-weight: 600; font-style: normal; font-display: swap; src: url('../fonts/inter-600.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-style: normal; font-display: swap; src: url('../fonts/jetbrains-mono-400.woff2') format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 500; font-style: normal; font-display: swap; src: url('../fonts/jetbrains-mono-500.woff2') format('woff2'); }

/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:             #0d0f14;
  --surface:        #161920;
  --surface2:       #1e2230;
  --surface3:       #252a3a;
  --border:         rgba(255,255,255,0.08);
  --border-strong:  rgba(255,255,255,0.14);
  --text:           #e8eaf0;
  --text-muted:     #9aa0b8;
  --text-dim:       #7e84a0;
  --accent:         #9485f9;
  --accent-bg:      rgba(124,106,247,0.12);
  --accent-border:  rgba(124,106,247,0.35);
  --success:        #3ecf8e;
  --success-bg:     rgba(62,207,142,0.08);
  --success-border: rgba(62,207,142,0.4);
  --radius:         8px;
  --font:           'Inter', sans-serif;
  --mono:           'JetBrains Mono', monospace;

  /* Distinct accent stripe per expansion, used in the command preview
     so multiple expansions are easy to tell apart at a glance. */
  --exp-color-ARR: #e2725b;
  --exp-color-HW:  #6ec6e8;
  --exp-color-SB:  #e8c84a;
  --exp-color-ShB: #8b7bd8;
  --exp-color-EW:  #5cc2a6;
  --exp-color-DT:  #e89a5c;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Header ───────────────────────────────────────────────── */
header {
  border-bottom: 1px solid var(--border);
  padding: 1.1rem 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 10;
}

.logo-icon {
  width: 34px;
  height: 34px;
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 17px;
  flex-shrink: 0;
}

header h1 { font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
header p  { font-size: 12px; color: var(--text-muted); margin-top: 1px; }

/* ── Main layout ──────────────────────────────────────────── */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (max-width: 600px) {
  main   { padding: 1rem; }
  header { padding: 1rem; }
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ── Expansion sections ───────────────────────────────────── */
.exp-section {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.exp-section-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 6px;
}

.exp-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: var(--radius);
  background: var(--accent-border);
  color: var(--accent);
}

.exp-divider {
  height: 1px;
  background: var(--accent-border);
  margin: 0.1rem 0;
}

.sub-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

/* ── Form elements ────────────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field > label {
  font-size: 12px;
  color: var(--text-muted);
}

.label-hint {
  font-weight: 400;
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-dim);
}

.row2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 480px) {
  .row2 { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="number"] {
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 10px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
}

input[type="text"]:focus,
input[type="number"]:focus {
  border-color: var(--accent);
}

input::placeholder { color: var(--text-dim); }

.targets-row {
  display: flex;
  align-items: center;
  gap: 7px;
}

.targets-row input[type="number"] {
  width: 64px;
}

.targets-sep {
  font-size: 14px;
  color: var(--text-muted);
}

/* ── Speed custom input ───────────────────────────────────── */
.speed-custom        { display: none; margin-top: 6px; }
.speed-custom.show   { display: block; }

/* ── Pills ────────────────────────────────────────────────── */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pill {
  padding: 4px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  cursor: pointer;
  background: var(--surface2);
  color: var(--text-muted);
  transition: all 0.12s;
  user-select: none;
}

.pill:hover {
  border-color: rgba(255,255,255,0.22);
  color: var(--text);
}

.pill.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* ── GIF quick-picks ──────────────────────────────────────── */
.gif-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 4px;
}

.gif-pick {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: all 0.12s;
}

.gif-pick:hover { color: var(--text); }

.gif-pick.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* Saved GIF pills (auto-built from localStorage) */
.gif-pick--saved {
  display: flex;
  align-items: center;
  gap: 3px;
  padding-right: 5px;
}

.gif-pick-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 110px;
}

.gif-pick-action {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 1px 2px;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color 0.12s;
  border-radius: 3px;
}

.gif-pick-action:hover { color: var(--text); }
.gif-pick-del:hover    { color: #e25c5c; }

/* GIF live preview */
#gif-name-row {
  margin-top: 6px;
}

#gif-url-hint {
  margin-top: 6px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-strong);
  background: var(--surface2);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
  display: flex;
  gap: 7px;
}

#gif-url-hint i { flex-shrink: 0; margin-top: 2px; }
#gif-url-hint .ti-check          { color: var(--success); }
#gif-url-hint .ti-alert-triangle { color: #e8a84a; }
#gif-url-hint .ti-loader         { color: var(--text-muted); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
#gif-url-hint strong { color: var(--text); }
#gif-url-hint code {
  font-family: var(--mono);
  font-size: 11px;
  background: var(--surface);
  padding: 1px 5px;
  border-radius: 4px;
}

#gif-preview {
  margin-top: 8px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: var(--surface2);
  max-width: 240px;
  min-height: 40px;
  position: relative;
}

#gif-preview img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 160px;
  object-fit: cover;
}

#gif-preview img[alt="Loading preview…"] {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font);
}

/* ── Progression toggle ───────────────────────────────────── */
.prog-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  user-select: none;
}

.prog-toggle input[type="checkbox"] {
  accent-color: var(--accent);
  width: 14px;
  height: 14px;
  cursor: pointer;
  flex-shrink: 0;
}

.prog-preview {
  font-size: 12px;
  color: var(--text-muted);
  font-family: var(--mono);
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  line-height: 1.6;
}

/* ── Combobox ─────────────────────────────────────────────── */
.combo { position: relative; width: 100%; }

.combo-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  padding: 7px 28px 7px 10px;
  outline: none;
  transition: border-color 0.15s;
}

.combo-input:focus       { border-color: var(--accent); }
.combo-input::placeholder { color: var(--text-dim); }

.combo-arrow {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
  font-size: 14px;
}

.combo-list {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
}

.combo-list.open { display: block; }

.combo-opt {
  padding: 7px 10px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: background 0.1s;
}

.combo-opt:hover,
.combo-opt.focused {
  background: var(--accent-bg);
  color: var(--accent);
}

.combo-empty {
  padding: 7px 10px;
  font-size: 13px;
  color: var(--text-dim);
}

/* ── Preview ──────────────────────────────────────────────── */
.preview-block + .preview-block { margin-top: 1rem; }

.exp-preview-divider {
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--border-strong) 15%,
    var(--border-strong) 85%,
    transparent
  );
  margin: 1.1rem 0;
}

.exp-icon {
  font-size: 13px;
  margin-right: 1px;
}

.preview-exp-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}

.preview-visual {
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  line-height: 2;
  white-space: pre-wrap;
  word-break: break-all;
  cursor: pointer;
  position: relative;
  transition: border-color 0.15s;
  user-select: none;
}

.preview-visual:hover  { border-color: var(--accent-border); }

.preview-visual.copied {
  border-color: var(--success-border);
  background: var(--success-bg);
}

/* Inline formatting spans — mirror Discord markdown visually */
.pv-bold   { font-weight: 700; }
.pv-italic { font-style: italic; color: var(--text-muted); }

/* Click-to-copy hint badge */
.copy-hint {
  position: absolute;
  top: 7px;
  right: 9px;
  font-size: 11px;
  font-family: var(--font);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  transition: color 0.15s;
}

.preview-visual:hover  .copy-hint { color: var(--accent); }
.preview-visual.copied .copy-hint { color: var(--success); }

/* Required-field validation */
.field-invalid {
  border-color: #e25c5c !important;
  box-shadow: 0 0 0 1px rgba(226, 92, 92, 0.35);
}

.preview-visual.blocked {
  border-color: #e25c5c;
  background: rgba(226, 92, 92, 0.08);
}

.preview-visual.blocked .copy-hint { color: #e25c5c; }

.no-exps {
  font-size: 13px;
  color: var(--text-dim);
  padding: 0.25rem 0;
}

/* ── Small command blocks (.start / .end) ─────────────────── */
.preview-visual.pv-small {
  line-height: 1.4;
  padding: 0.55rem 0.85rem;
  min-height: unset;
}

/* ── Countdown timer panel ────────────────────────────────── */
#timer-panel {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 500;
  width: 190px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 0.8rem 0.9rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
}

/* Counting up past zero — train is running late / overtime */
#timer-panel.overtime {
  border-color: #e8a84a;
  box-shadow: 0 8px 28px rgba(232, 168, 74, 0.2);
}

/* Paused — session exists but not currently counting */
#timer-panel.paused {
  border-color: var(--border-strong);
  opacity: 0.8;
}

.timer-head {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.timer-head i { color: var(--accent); font-size: 14px; }

#timer-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  padding: 2px;
  line-height: 1;
  border-radius: 4px;
}

#timer-close:hover { color: #e25c5c; }

#timer-display {
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 500;
  text-align: center;
  color: var(--text);
  letter-spacing: 0.03em;
  line-height: 1.1;
  transition: color 0.2s;
}

#timer-panel.overtime #timer-display { color: #e8a84a; }
#timer-panel.paused #timer-display   { color: var(--text-muted); }

.timer-controls {
  display: flex;
  gap: 5px;
}

.timer-controls input[type="text"] {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  padding: 5px 6px;
}

.timer-controls select {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  padding: 5px 6px;
  outline: none;
}

.timer-controls button {
  background: var(--surface2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 5px 9px;
  display: flex;
  align-items: center;
  transition: all 0.12s;
  flex: 1;
  justify-content: center;
}

.timer-controls button:hover {
  color: var(--accent);
  border-color: var(--accent-border);
}

#timer-pause {
  color: var(--accent);
  border-color: var(--accent-border);
}

@media (max-width: 600px) {
  #timer-panel { bottom: 10px; right: 10px; width: 170px; }
  #timer-display { font-size: 28px; }
}
/* Footer with the privacy link */
.site-foot { text-align: center; padding: 24px 16px 40px; font-size: 12px; }
.site-foot a { color: var(--text-dim); }
.site-foot a:hover { color: var(--text); }
