:root {
  --bg: #0f1115;
  --panel: #171a21;
  --text: #e8eaef;
  --muted: #8b93a7;
  --yt: #ff4e45;
  --tw: #9146ff;
  --web: #38bdf8;
  --pending: #f0c14b;
  --speaking: #5bbcff;
  --spoken: #3dd68c;
  --skipped: #6b7280;
  --failed: #ff6b6b;
  --blocked: #fb7185;
  --border: #262b36;
  --accent: #2b6fff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.45 "Segoe UI", system-ui, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 600px at 10% -10%, #1a2233 0%, var(--bg) 55%);
}

header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 20px 24px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 2;
}

h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.02em;
}

h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

h3 {
  margin: 20px 0 8px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
}

.sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.hint {
  color: var(--muted);
  margin: 0 0 12px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 8px;
}

.section-head h2 {
  margin: 0;
}

.char-count {
  margin: 0;
  font-size: 12px;
  white-space: nowrap;
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-top: 12px;
  width: 100%;
}

.style-grid label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.style-grid select,
.style-grid input[type="color"] {
  width: 100%;
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 8px;
  font: inherit;
  box-sizing: border-box;
}

.style-grid input[type="color"] {
  padding: 4px;
  cursor: pointer;
}

.alert-preview {
  margin-top: 12px;
  padding: 16px 12px;
  border-radius: 10px;
  border: 1px dashed var(--border);
  background:
    linear-gradient(45deg, #2a2f3a 25%, transparent 25%) 0 0 / 16px 16px,
    linear-gradient(-45deg, #2a2f3a 25%, transparent 25%) 0 8px / 16px 16px,
    #1a1f29;
  text-align: center;
  font-size: clamp(22px, 4vw, 32px);
  font-weight: 800;
  line-height: 1.25;
  color: #fff;
  -webkit-text-stroke: 2px #000;
  paint-order: stroke fill;
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: var(--accent);
  color: white;
  font-weight: 600;
  cursor: pointer;
}

button:hover:not(:disabled) {
  filter: brightness(1.08);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.ghost {
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
}

button.paused {
  background: #b45309;
}

.banners {
  padding: 12px 24px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 960px;
}

.banner {
  border-radius: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  background: var(--panel);
}

.banner.error {
  border-color: rgba(255, 107, 107, 0.55);
  background: rgba(255, 107, 107, 0.1);
}

.banner-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.banner-note {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--failed);
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  gap: 4px;
  padding: 12px clamp(12px, 3vw, 24px) 0;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  width: 100%;
  max-width: 960px;
  box-sizing: border-box;
  background: rgba(15, 17, 21, 0.92);
  backdrop-filter: blur(10px);
}

.tab {
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
  padding: 12px 14px;
  margin-bottom: -1px;
}

.tab:hover:not(:disabled) {
  filter: none;
  color: var(--text);
  background: transparent;
}

.tab.active {
  background: transparent;
  color: var(--text);
  border-bottom-color: var(--text);
}

.tab-panel {
  padding: 16px clamp(12px, 3vw, 24px) 40px;
  width: 100%;
  max-width: 960px;
  box-sizing: border-box;
}

.submit-form {
  width: 100%;
}

.submit-form textarea {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 12px;
  resize: vertical;
  font: inherit;
}

.form-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.cooldown {
  color: var(--pending);
  font-weight: 600;
  font-size: 13px;
}

.feedback {
  margin-top: 10px;
  color: var(--spoken);
}

.feedback.error-text {
  color: var(--failed);
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr));
  gap: 12px;
  width: 100%;
}

.media-card {
  display: block;
  width: 100%;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  box-sizing: border-box;
}

.media-card img,
.thumb {
  width: 100%;
  height: auto;
  max-height: 160px;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  border-radius: 6px;
  background: #0b0d12;
  display: block;
}

.stats {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 0 12px;
}

.pill {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 12px;
}

#feed,
.mini-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  box-sizing: border-box;
}

.row.alert-row {
  grid-template-columns: minmax(0, 1fr) auto;
}

.row.alert-row .alert-body {
  min-width: 0;
}

.row.speaking {
  border-color: #3b82f6;
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.25);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 24px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge.YT {
  background: rgba(255, 78, 69, 0.15);
  color: var(--yt);
}

.badge.TW {
  background: rgba(145, 70, 255, 0.15);
  color: var(--tw);
}

.badge.WEB {
  background: rgba(56, 189, 248, 0.15);
  color: var(--web);
}

.badge.SYS {
  background: rgba(59, 130, 246, 0.15);
  color: #93c5fd;
}

.kind-tag {
  margin-left: 8px;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.author {
  font-weight: 650;
}

.text {
  color: var(--text);
  overflow-wrap: anywhere;
  word-break: normal;
  white-space: normal;
  line-height: 1.45;
}

.send-count {
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.meta {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

@media (max-width: 640px) {
  .tabs {
    gap: 2px;
    padding-top: 10px;
  }

  .tab {
    font-size: 18px;
    padding: 14px 12px;
  }

  .row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .row .meta {
    grid-column: 2;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
  }

  .row.alert-row {
    grid-template-columns: minmax(0, 1fr);
  }

  .row.alert-row .meta {
    grid-column: 1;
    margin-top: 2px;
  }

  .row .meta .status {
    line-height: 1;
    display: inline-flex;
    align-items: center;
  }

  .row .meta button.retry {
    margin: 0;
    line-height: 1;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(110px, 100%), 1fr));
    gap: 8px;
  }
}

button.retry {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  color: var(--text);
}

button.retry:hover {
  border-color: #3b82f6;
  color: #93c5fd;
}

.error {
  margin-top: 4px;
  font-size: 11px;
  color: var(--failed);
  max-width: 520px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.status.pending {
  color: var(--pending);
}
.status.speaking {
  color: var(--speaking);
}
.status.spoken {
  color: var(--spoken);
}
.status.skipped {
  color: var(--skipped);
}
.status.failed {
  color: var(--failed);
}
.status.blocked {
  color: var(--blocked);
}

.empty {
  color: var(--muted);
  padding: 24px 0;
}

.suggest-form {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
}

.suggest-form h3 {
  margin: 0;
}

.suggest-form input[type="text"],
.suggest-form input[type="file"] {
  width: 100%;
  box-sizing: border-box;
}

.sounds-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 12px;
  width: 100%;
}

.sound-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sound-card audio {
  width: 100%;
}

.sound-label {
  font-weight: 650;
}

.modal[hidden] {
  display: none !important;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  max-height: min(90vh, 900px);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-card img {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  background: #0b0d12;
  border-radius: 8px;
}

.modal-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  padding: 0;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
}

.admin-login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
  color: var(--muted);
}

.admin-login-form input {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font: inherit;
}

.admin-frame {
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0b0d12;
}

.ghost-link {
  background: transparent;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 4px 0;
  cursor: pointer;
}

.ghost-link:hover {
  color: var(--text);
}
