/* ── Reset ─────────────────────────────────────────────────────────────── */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

[hidden] { display: none !important; }

/* ── Design tokens ─────────────────────────────────────────────────────── */

:root {
  --bg:              #0b0e12;
  --surface:         #111519;
  --surface-2:       #161c24;
  --border:          #1c2530;
  --border-hi:       #2a3a4e;

  --amber:           #f0a32c;
  --amber-dim:       rgba(240, 163, 44, 0.12);
  --amber-mid:       #7a5214;

  --cyan:            #38bdf8;
  --cyan-dim:        rgba(56, 189, 248, 0.12);

  --green:           #4ade80;
  --green-dim:       rgba(74, 222, 128, 0.1);

  --red:             #f87171;
  --red-dim:         rgba(248, 113, 113, 0.1);

  --text:            #7a9ab8;
  --text-bright:     #c8dff0;
  --text-muted:      #2e4256;

  --font:            'Share Tech Mono', 'Courier New', monospace;
  --radius:          0;
}

/* ── Base ──────────────────────────────────────────────────────────────── */

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Dot-grid atmosphere */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, var(--border) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

/* ── Auth screen ───────────────────────────────────────────────────────── */

#auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-box {
  width: 100%;
  max-width: 360px;
  border: 1px solid var(--border-hi);
  background: var(--surface);
  padding: 32px 28px;
  animation: slide-up 0.35s ease-out both;
}

.auth-logo {
  font-size: 16px;
  letter-spacing: 0.35em;
  color: var(--amber);
  margin-bottom: 4px;
}

.auth-sub {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  margin-bottom: 20px;
}

.auth-form {
  display: flex;
  gap: 0;
}

.auth-form input {
  border-right: none;
}

.auth-error {
  margin-top: 10px;
  font-size: 11px;
  color: var(--red);
}

/* ── Main screen ───────────────────────────────────────────────────────── */

#main-screen {
  width: 100%;
  min-height: 100vh;
  padding: 0 16px;
}

.container {
  max-width: 740px;
  margin: 0 auto;
  padding: 28px 0 64px;
}

/* Staggered entrance animation */
.container > * {
  animation: slide-up 0.3s ease-out both;
}
.container > *:nth-child(1) { animation-delay: 0.00s; }
.container > *:nth-child(2) { animation-delay: 0.05s; }
.container > *:nth-child(3) { animation-delay: 0.08s; }
.container > *:nth-child(4) { animation-delay: 0.11s; }
.container > *:nth-child(5) { animation-delay: 0.14s; }

/* ── Header ────────────────────────────────────────────────────────────── */

header {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.app-title {
  font-size: 12px;
  letter-spacing: 0.35em;
  color: var(--amber);
}

.feed-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.row-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 32px;
}

.feed-url {
  flex: 1;
  color: var(--text);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* ── Inputs ────────────────────────────────────────────────────────────── */

input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-bright);
  font-family: var(--font);
  font-size: 13px;
  padding: 8px 10px;
  outline: none;
  flex: 1;
  min-width: 0;
  transition: border-color 0.15s, background 0.15s;
}

input:focus {
  border-color: var(--amber-mid);
  background: var(--bg);
}

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

/* ── Buttons ───────────────────────────────────────────────────────────── */

button {
  background: transparent;
  border: 1px solid var(--border-hi);
  color: var(--text);
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 0.1em;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

button:hover:not(:disabled) {
  border-color: var(--amber);
  color: var(--amber);
}

button:disabled {
  opacity: 0.3;
  cursor: default;
}

.btn-ghost {
  font-size: 10px;
  letter-spacing: 0.12em;
  padding: 4px 10px;
  border-color: var(--border);
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--red);
  color: var(--red);
}

.btn-copy {
  font-size: 10px;
  letter-spacing: 0.1em;
  padding: 4px 10px;
  border-color: var(--border);
  color: var(--text-muted);
}

/* ── Submit area ───────────────────────────────────────────────────────── */

.submit-area {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 10px;
}

.prompt {
  color: var(--amber);
  font-size: 13px;
  padding-right: 8px;
  flex-shrink: 0;
  line-height: 1;
  padding-top: 1px;
}

/* Join input + button visually */
.submit-area input {
  border-right: none;
}

.submit-area input:focus {
  border-right: none;
}

/* ── Flash messages ────────────────────────────────────────────────────── */

#flash {
  font-size: 11px;
  padding: 5px 10px;
  margin-bottom: 10px;
  border-left: 2px solid;
  letter-spacing: 0.02em;
}

#flash.ok {
  color: var(--green);
  border-color: var(--green);
  background: var(--green-dim);
}

#flash.err {
  color: var(--red);
  border-color: var(--red);
  background: var(--red-dim);
}

/* ── Episode list header ───────────────────────────────────────────────── */

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  letter-spacing: 0.15em;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 5px 0;
  margin-bottom: 2px;
}

.ep-count {
  color: var(--text-muted);
}

/* ── Episode rows ──────────────────────────────────────────────────────── */

.episode-list {
  display: flex;
  flex-direction: column;
}

.episode-row {
  border-bottom: 1px solid var(--border);
  padding: 7px 0;
}

.episode-row:last-child {
  border-bottom: none;
}

.ep-main {
  display: grid;
  grid-template-columns: 76px 1fr 36px 52px;
  align-items: baseline;
  gap: 6px;
  min-width: 0;
}

/* Status badge */
.ep-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  letter-spacing: 0.05em;
  overflow: hidden;
}

.ep-dot {
  font-size: 7px;
  flex-shrink: 0;
  position: relative;
  top: -1px;
}

.ep-label {
  font-size: 10px;
  letter-spacing: 0.08em;
}

.ep-title {
  color: var(--text-bright);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.ep-time {
  font-size: 10px;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
}

.ep-actions {
  display: flex;
  gap: 2px;
  justify-content: flex-end;
  align-items: center;
}

/* Icon-style action buttons */
.ep-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font);
  font-size: 14px;
  padding: 0 3px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.12s;
  flex-shrink: 0;
}

.ep-btn:hover {
  background: transparent;
  border-color: transparent;
}

.ep-btn.retry:hover { color: var(--amber); }
.ep-btn.del:hover   { color: var(--red); }

/* Error message under episode */
.ep-error {
  font-size: 11px;
  color: var(--red);
  padding-left: 82px;
  margin-top: 3px;
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty state */
.empty-state {
  padding: 24px 0;
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.05em;
}

/* ── Status colours ────────────────────────────────────────────────────── */

.ep-row-pending     .ep-dot,
.ep-row-pending     .ep-label { color: var(--amber); }

.ep-row-downloading .ep-dot,
.ep-row-downloading .ep-label,
.ep-row-uploading   .ep-dot,
.ep-row-uploading   .ep-label { color: var(--cyan); }

.ep-row-ready       .ep-dot,
.ep-row-ready       .ep-label { color: var(--green); }

.ep-row-failed      .ep-dot,
.ep-row-failed      .ep-label { color: var(--red); }

/* Pulse for in-progress states */
.ep-row-downloading .ep-dot,
.ep-row-uploading   .ep-dot {
  animation: pulse 1.6s ease-in-out infinite;
}

/* ── Animations ────────────────────────────────────────────────────────── */

@keyframes slide-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.25; }
}

/* ── Mobile ────────────────────────────────────────────────────────────── */

@media (max-width: 540px) {
  .ep-main {
    grid-template-columns: 64px 1fr 30px 44px;
    gap: 4px;
  }

  .ep-error {
    padding-left: 0;
  }
}
