:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --border: #e4e2d9;
  --text: #24231f;
  --text-secondary: #6d6c64;
  --text-muted: #9b9a90;
  --accent: #2c5f8a;
  --accent-bg: #e6f0f7;
  --danger: #b23b3b;
  --radius: 8px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; text-decoration: none; }

button, select, input {
  font-family: inherit;
  font-size: 14px;
}

button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  color: var(--text);
}
button:hover { background: var(--accent-bg); border-color: var(--accent); }

input[type="text"], input:not([type]), select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  background: var(--surface);
  color: var(--text);
}

.app {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
}

.sidebar .brand {
  font-weight: 600;
  font-size: 16px;
  padding: 4px 8px 16px;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius);
  color: var(--text-secondary);
}

.sidebar nav a:hover { background: var(--bg); color: var(--text); }
.sidebar nav a.active { background: var(--accent-bg); color: var(--accent); font-weight: 600; }
.sidebar nav .icon { width: 18px; text-align: center; }

.main {
  flex: 1;
  min-width: 0;
  padding: 20px 28px;
  max-width: 760px;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.view-header h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0;
}

.view-header .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.back-link {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 12px;
  display: inline-block;
}
.back-link:hover { color: var(--accent); }

/* 카드 목록 (4-1) */
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.entry-card {
  display: flex;
  gap: 12px;
  padding: 8px;
  border-radius: var(--radius);
  position: relative;
}
.entry-card:hover { background: var(--surface); }

.entry-card .thumb {
  width: 140px;
  aspect-ratio: 16 / 9;
  background: var(--border);
  border-radius: 6px;
  flex-shrink: 0;
  object-fit: cover;
}

.entry-card .body { flex: 1; min-width: 0; }
.entry-card .title { font-weight: 600; margin-bottom: 4px; }
.entry-card .meta { color: var(--text-muted); font-size: 12px; }

.entry-card.read .title,
.entry-card.read .summary { opacity: 0.45; }

.entry-card .icon-row {
  position: absolute;
  top: 6px;
  right: 6px;
  display: none;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2px;
}
.entry-card:hover .icon-row { display: flex; }

.icon-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  padding: 0;
}
.icon-btn:hover { background: var(--accent-bg); }
.icon-btn.on { color: var(--accent); }

.later-badge {
  color: var(--accent);
  font-size: 12px;
}

.empty-state {
  text-align: center;
  color: var(--text-secondary);
  padding: 48px 16px;
}
.empty-state .actions { justify-content: center; margin-top: 12px; }

.skeleton-list { display: flex; flex-direction: column; gap: 8px; }
.skeleton-row {
  height: 76px;
  border-radius: var(--radius);
  background: linear-gradient(90deg, var(--border) 25%, var(--bg) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* 단순 목록 (재생목록/보관함 목록) */
.simple-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.simple-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.simple-list .name { font-weight: 600; }
.simple-list .sub { color: var(--text-secondary); font-size: 13px; }

.bar {
  display: inline-block;
  width: 100px;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  vertical-align: middle;
  overflow: hidden;
}
.bar-fill { display: block; height: 6px; background: var(--accent); }

.create-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

/* 팝업 */
.popup-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.popup {
  background: var(--surface);
  border-radius: 12px;
  padding: 16px;
  width: 320px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.popup h3 { margin: 0; font-size: 15px; }
.popup-list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.popup-list button { text-align: left; width: 100%; }
.popup .row { display: flex; gap: 8px; }
.popup .row input { flex: 1; }

.toast {
  display: none;
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--surface);
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  align-items: center;
  gap: 10px;
  z-index: 60;
}
.toast button { background: transparent; border-color: rgba(255,255,255,0.4); color: var(--surface); }

/* 플레이어 화면 (4-3) */
.player-shell { max-width: 640px; }
.player-shell #player { width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden; background: #000; }
.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0 20px;
}
.player-item-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0;
  margin: 0;
  list-style: none;
}
.player-item-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
}
.player-item-list li:hover { background: var(--surface); }
.player-item-list li.current { background: var(--accent-bg); font-weight: 600; }
.player-item-list li.completed { color: var(--text-muted); }
.player-item-list .idx { width: 20px; color: var(--text-muted); font-size: 12px; }
.player-item-list .info { flex: 1; min-width: 0; }
.player-item-list .status { font-size: 12px; color: var(--text-muted); white-space: nowrap; }

@media (max-width: 700px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%;
    order: 2;
    position: sticky;
    bottom: 0;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 6px 4px;
  }
  .sidebar .brand { display: none; }
  .sidebar nav { flex-direction: row; justify-content: space-around; }
  .sidebar nav a { flex-direction: column; font-size: 11px; gap: 2px; }
  .main { order: 1; padding: 16px; max-width: none; }
  .entry-card .thumb { width: 110px; }
}
