:root {
  --primary-color: #00add8; /* Go Cyan */
  --primary-dark: #007d9c;
  --primary-light: #e0f7fa;
  --accent-color: #5dc9e2;
  --bg-color: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --sidebar-bg: #ffffff;
  --code-bg: #0f172a;
  --code-header-bg: #1e293b;
  --code-text: #f8fafc;
  --console-bg: #020617;
  --console-text: #4ade80;
  --tip-bg: #eff6ff;
  --tip-border: #3b82f6;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --header-height: 64px;
  --sidebar-width: 320px;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

[data-theme="dark"] {
  --bg-color: #0b0f19;
  --card-bg: #131b2e;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --border-color: #1e293b;
  --sidebar-bg: #111827;
  --tip-bg: #172554;
  --tip-border: #60a5fa;
  --primary-light: rgba(0, 173, 216, 0.15);
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color 0.25s, color 0.25s;
}

/* Header */
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 50;
  backdrop-filter: blur(8px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-main);
  cursor: pointer;
  padding: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-main);
  font-weight: 800;
  font-size: 1.25rem;
}

.brand-badge {
  background: linear-gradient(135deg, #00add8, #007d9c);
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-text span {
  color: var(--primary-color);
}

.header-center {
  flex: 1;
  max-width: 450px;
  margin: 0 24px;
  position: relative;
}

.search-wrapper {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  padding: 8px 16px 8px 38px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
  background: var(--bg-color);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  transition: all 0.2s;
}

.search-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.progress-container {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.progress-bar-track {
  width: 120px;
  height: 8px;
  background: var(--border-color);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-color), var(--success-color));
  width: 0%;
  transition: width 0.3s ease;
}

.header-btn {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  transition: all 0.2s;
}

.header-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.theme-toggle-btn {
  font-size: 1.1rem;
  padding: 6px 10px;
}

/* Layout */
.app-container {
  display: flex;
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height));
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  position: fixed;
  top: var(--header-height);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  padding: 20px 16px 40px;
  z-index: 40;
  transition: transform 0.3s ease;
}

.sidebar-section-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  font-weight: 700;
  margin: 18px 8px 8px;
}

.sidebar-nav-list {
  list-style: none;
}

.nav-item {
  margin-bottom: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-main);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.2s;
  cursor: pointer;
}

.nav-link:hover {
  background: var(--primary-light);
  color: var(--primary-dark);
}

[data-theme="dark"] .nav-link:hover {
  color: var(--accent-color);
}

.nav-link.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 700;
  border-left: 3px solid var(--primary-color);
}

[data-theme="dark"] .nav-link.active {
  color: var(--accent-color);
}

.nav-link-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topic-check-icon {
  color: var(--success-color);
  font-size: 0.9rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.nav-item.completed .topic-check-icon {
  opacity: 1;
}

.nav-badge {
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--border-color);
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

/* Main Content Area */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 36px 48px 60px;
  max-width: 1080px;
}

.content-header {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
}

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

.category-tag {
  color: var(--primary-color);
  font-weight: 700;
  font-size: 0.9rem;
}

.topic-title {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.3;
  margin-bottom: 12px;
}

.topic-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
}

.btn-complete-toggle {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-complete-toggle:hover {
  border-color: var(--success-color);
  color: var(--success-color);
}

.btn-complete-toggle.is-completed {
  background: rgba(16, 185, 129, 0.1);
  border-color: var(--success-color);
  color: var(--success-color);
}

/* Content Body Typography */
.content-body {
  font-size: 1rem;
  color: var(--text-main);
}

.content-body h3 {
  font-size: 1.4rem;
  margin: 28px 0 14px;
  color: var(--text-main);
  font-weight: 700;
}

.content-body h4 {
  font-size: 1.15rem;
  margin: 20px 0 10px;
  font-weight: 700;
}

.content-body p {
  margin-bottom: 14px;
  color: var(--text-main);
  opacity: 0.92;
}

.content-body ul, .content-body ol {
  margin: 12px 0 18px 24px;
}

.content-body li {
  margin-bottom: 6px;
}

.content-body code:not(pre code) {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
}

[data-theme="dark"] .content-body code:not(pre code) {
  background: rgba(0, 173, 216, 0.15);
  color: var(--accent-color);
}

.code-box-plain {
  background: var(--code-bg);
  color: #38bdf8;
  padding: 14px 18px;
  border-radius: 8px;
  font-family: 'Fira Code', monospace;
  font-size: 0.88rem;
  margin: 12px 0 18px;
  line-height: 1.5;
  border: 1px solid var(--border-color);
}

/* Key Points Card */
.keypoints-box {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary-color);
  border-radius: 8px;
  padding: 16px 20px;
  margin: 20px 0 28px;
  box-shadow: var(--shadow-sm);
}

.keypoints-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary-color);
}

.keypoints-box ul {
  margin: 0 0 0 20px;
}

.keypoints-box li {
  margin-bottom: 4px;
  font-size: 0.92rem;
}

/* Code Viewer Card */
.code-card {
  background: var(--code-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  margin: 28px 0;
  border: 1px solid #334155;
}

.code-header {
  background: var(--code-header-bg);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #334155;
}

.code-title {
  color: #94a3b8;
  font-size: 0.82rem;
  font-family: 'Fira Code', monospace;
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-dots {
  display: flex;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.dot.red { background: #ef4444; }
.dot.yellow { background: #f59e0b; }
.dot.green { background: #10b981; }

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

.code-btn {
  background: #334155;
  color: #e2e8f0;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  text-decoration: none;
}

.code-btn:hover {
  background: #475569;
  color: #ffffff;
}

.code-btn.btn-play {
  background: #00add8;
  color: #ffffff;
}

.code-btn.btn-play:hover {
  background: #007d9c;
}

.code-container {
  padding: 16px 20px;
  overflow-x: auto;
}

.code-container pre {
  margin: 0;
}

.code-container code {
  font-family: 'Fira Code', 'Consolas', monospace;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--code-text);
  white-space: pre;
}

/* Console Output Card */
.console-card {
  background: var(--console-bg);
  border: 1px solid #1e293b;
  border-radius: 10px;
  margin: 20px 0 28px;
  overflow: hidden;
}

.console-header {
  background: #0f172a;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #1e293b;
  color: #94a3b8;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.console-body {
  padding: 14px 18px;
  font-family: 'Fira Code', monospace;
  font-size: 0.88rem;
  color: var(--console-text);
  white-space: pre-wrap;
  line-height: 1.5;
  max-height: 300px;
  overflow-y: auto;
}

/* Tips Box */
.tip-card {
  background: var(--tip-bg);
  border-left: 4px solid var(--tip-border);
  padding: 16px 20px;
  border-radius: 8px;
  margin: 24px 0 32px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.tip-icon {
  font-size: 1.3rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.tip-content {
  font-size: 0.92rem;
  line-height: 1.5;
}

.tip-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-main);
}

/* Navigation Buttons (Prev / Next) */
.topic-navigator {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border-color);
}

.nav-btn-box {
  flex: 1;
  max-width: 320px;
  padding: 16px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--card-bg);
  text-decoration: none;
  color: var(--text-main);
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
}

.nav-btn-box:hover {
  border-color: var(--primary-color);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.nav-btn-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 4px;
}

.nav-btn-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-btn-box.next {
  text-align: right;
  margin-left: auto;
}

/* Live Playground Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.playground-modal {
  background: var(--card-bg);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-color);
}

.modal-header {
  padding: 16px 24px;
  background: var(--code-header-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h3 {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 1.4rem;
  cursor: pointer;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  flex: 1;
}

.playground-editor {
  width: 100%;
  height: 280px;
  background: #0f172a;
  color: #f8fafc;
  font-family: 'Fira Code', monospace;
  font-size: 0.9rem;
  padding: 14px;
  border-radius: 8px;
  border: 1px solid #334155;
  resize: vertical;
  outline: none;
  line-height: 1.5;
}

.playground-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 14px 0;
}

.btn-run-go {
  background: #00add8;
  color: #fff;
  border: none;
  padding: 9px 20px;
  border-radius: 8px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
}

.btn-run-go:hover {
  background: #007d9c;
}

.playground-output-box {
  background: #020617;
  color: #4ade80;
  font-family: 'Fira Code', monospace;
  padding: 14px;
  border-radius: 8px;
  min-height: 120px;
  max-height: 220px;
  overflow-y: auto;
  white-space: pre-wrap;
  font-size: 0.88rem;
  border: 1px solid #1e293b;
}

/* Toast */
.toast-notification {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: #1e293b;
  color: #ffffff;
  padding: 12px 22px;
  border-radius: 30px;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  border: 1px solid #334155;
}

.toast-notification.show {
  transform: translateY(0);
  opacity: 1;
}

/* Responsive */
@media (max-width: 900px) {
  .menu-toggle {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-content {
    margin-left: 0;
    padding: 24px 20px 40px;
  }

  .header-center {
    display: none;
  }
}

@media (max-width: 600px) {
  .topic-title {
    font-size: 1.6rem;
  }

  .topic-navigator {
    flex-direction: column;
  }

  .nav-btn-box {
    max-width: 100%;
  }

  .progress-container {
    display: none;
  }
}
