/* Great Apps Framework — Shared UI for the Great Apps suite */

:root {
  --bg: #0f0f13;
  --bg-surface: #1a1a24;
  --bg-hover: #24243a;
  --bg-active: #2d2d4a;
  --text: #e8e6f0;
  --text-muted: #8888a8;
  --accent: #7c6fff;
  --accent-dim: #5a4fd4;
  --border: #2a2a3e;
  --radius: 8px;
}

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

html {
  background: var(--bg);
  min-height: 100%;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

/* ── Views ─────────────────────────────── */
.view {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

/* ── List View ─────────────────────────── */
.list-header {
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  flex-shrink: 0;
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-row h1 {
  font-size: 1.25rem;
  font-weight: 400;
}

.header-accent {
  color: #4A90E2;
  font-weight: 700;
}

.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.15s, color 0.15s;
}

.icon-btn:hover {
  border-color: var(--accent);
  color: var(--text);
}

/* ── Search Bar ────────────────────────── */
.search-bar {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.search-bar input[type="text"] {
  flex: 1;
  padding: 8px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input[type="text"]:focus {
  border-color: var(--accent);
}

.search-bar input[type="text"]::placeholder {
  color: var(--text-muted);
}

.search-bar select {
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
}

/* ── Item List ─────────────────────────── */
.item-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
}

.item-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  transition: background 0.12s;
  -webkit-tap-highlight-color: transparent;
  gap: 12px;
}

.item-row:hover { background: var(--bg-hover); }
.item-row:active { background: var(--bg-active); }
.item-row.active { background: var(--bg-active); }

.item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

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

.item-title {
  font-size: 0.95rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Play Button ───────────────────────── */
.play-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.play-btn:hover {
  color: var(--text);
  border-color: var(--accent);
}

.play-btn.playing {
  color: var(--accent);
  border-color: var(--accent);
}

/* ── Pills / Badges ────────────────────── */
.pill {
  font-size: 0.75rem;
  padding: 3px 10px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
  font-weight: 500;
}

.pill-accent {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 14px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--accent-dim);
  color: white;
}

.pill-tag {
  font-size: 0.65rem;
  padding: 2px 8px;
  background: rgba(124, 111, 255, 0.15);
  border: 1px solid rgba(124, 111, 255, 0.3);
  border-radius: 4px;
  color: var(--text);
  flex-shrink: 0;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.year-badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  width: 36px;
  text-align: center;
}

/* ── List Footer ───────────────────────── */
.list-footer {
  padding: 6px 16px;
  padding-bottom: max(6px, env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  flex-shrink: 0;
  position: relative;
  background: var(--bg-surface);
}

.version-label {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
  font-size: 0.65rem;
}

.copyright {
  display: block;
  font-size: 0.65rem;
  color: var(--text-muted);
  opacity: 0.6;
  margin-top: 2px;
}

/* ── Detail View ───────────────────────── */
.detail-header {
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.back-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  padding: 6px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  -webkit-tap-highlight-color: transparent;
}

.back-btn svg { flex-shrink: 0; }

.detail-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding: 24px 20px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}

.detail-body h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 8px;
  line-height: 1.3;
}

.detail-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.meta-text {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ── Audio Player ──────────────────────── */
.audio-section {
  margin-bottom: 24px;
}

.audio-section audio {
  width: 100%;
  border-radius: var(--radius);
  height: 48px;
}

.audio-section audio::-webkit-media-controls-panel {
  background: var(--bg-surface);
}

/* ── Content Section ───────────────────── */
.content-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.content-section h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-weight: 600;
}

.content-text {
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--text);
  white-space: pre-wrap;
}

/* ── Desktop ───────────────────────────── */
@media (min-width: 769px) {
  .detail-body {
    max-width: 640px;
    margin: 0 auto;
    padding: 32px 24px;
  }
}

/* ── Mobile ────────────────────────────── */
@media (max-width: 768px) {
  .item-row {
    padding: 14px 16px;
    min-height: 52px;
  }

  .search-bar input[type="text"] {
    flex: 1 1 100%;
    padding: 12px 14px;
    font-size: 1rem;
  }

  .search-bar select {
    flex: 1 1 0;
    min-width: 0;
    padding: 12px 10px;
    font-size: 0.9rem;
  }
}
