/* ========================================
   Design Tokens
   ======================================== */
:root {
  /* Colors */
  --bg: #f5efe5;
  --bg-gradient:
    radial-gradient(circle at top left, rgba(217, 130, 43, 0.16), transparent 24%),
    radial-gradient(circle at right 16%, rgba(47, 125, 116, 0.13), transparent 22%),
    linear-gradient(180deg, #fcf8f2 0%, var(--bg) 100%);
  
  --surface: rgba(255, 252, 248, 0.92);
  --surface-strong: #fffaf3;
  --surface-hover: rgba(255, 255, 255, 0.95);
  
  --ink: #102a43;
  --ink-light: #243b53;
  --muted: #5f6c7b;
  --muted-light: #8b9aad;
  
  --gold: #d9822b;
  --teal: #2f7d74;
  --coral: #b23a48;
  --slate: #8b9aad;
  
  --line: rgba(16, 42, 67, 0.12);
  --line-strong: rgba(16, 42, 67, 0.2);
  --line-teal: rgba(47, 125, 116, 0.24);
  
  /* Shadows */
  --shadow-sm: 0 4px 12px rgba(16, 42, 67, 0.06);
  --shadow: 0 12px 28px rgba(16, 42, 67, 0.08);
  --shadow-lg: 0 22px 60px rgba(16, 42, 67, 0.1);
  --shadow-hover: 0 16px 32px rgba(16, 42, 67, 0.12);
  
  /* Spacing Scale */
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 40px;
  --space-3xl: 48px;
  
  /* Border Radius */
  --radius-sm: 12px;
  --radius: 18px;
  --radius-lg: 24px;
  --radius-xl: 28px;
  --radius-2xl: 34px;
  --radius-full: 9999px;
  
  /* Typography */
  --font-sans: "Inter", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "JetBrains Mono", "Consolas", "SFMono-Regular", monospace;
  
  /* Transitions */
  --transition-fast: 150ms ease;
  --transition: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ========================================
   Reset & Base
   ======================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg-gradient);
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--teal);
}

img,
svg {
  display: block;
  max-width: 100%;
}

/* ========================================
   Layout System
   ======================================== */
.shell {
  width: min(1400px, calc(100% - 48px));
  margin: var(--space-xl) auto var(--space-3xl);
}

.shell-app,
.shell-admin {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* Hero Sections */
.hero {
  display: grid;
  gap: var(--space-lg);
  padding: var(--space-xl);
  border: 1px solid var(--line);
  border-radius: var(--radius-2xl);
  background: linear-gradient(135deg, rgba(255, 249, 240, 0.98), rgba(246, 239, 227, 0.88));
  box-shadow: var(--shadow-lg);
}

.hero-app {
  grid-template-columns: minmax(0, 1.2fr) minmax(380px, 0.8fr);
}

.hero-admin {
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
}

.hero-copy {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.brand svg {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
}

.hero-tag,
.section-tag {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
}

.hero h1 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}

.hero strong {
  display: block;
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  font-weight: 800;
  line-height: 1.2;
  color: var(--ink);
  white-space: nowrap;
}

.hero-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.hero-badges span {
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  background: rgba(16, 42, 67, 0.06);
  border: 1px solid rgba(16, 42, 67, 0.08);
  font-size: 0.85rem;
  font-weight: 500;
}

/* App Layout */
.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(380px, 0.7fr);
  gap: var(--space-lg);
  align-items: start;
}

.detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(340px, 0.75fr);
  gap: var(--space-lg);
  align-items: start;
}

.admin-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(340px, 0.9fr);
  gap: var(--space-lg);
  align-items: start;
}

.content-stack,
.detail-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

.sidebar-stack,
.detail-side,
.admin-side {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  position: sticky;
  top: var(--space-lg);
  max-height: calc(100vh - var(--space-xl));
  overflow-y: auto;
}

/* ========================================
   Components: Panels & Cards
   ======================================== */
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: var(--space-lg);
  transition: box-shadow var(--transition);
}

.panel:hover {
  box-shadow: var(--shadow-hover);
}

.panel-heading,
.section-heading,
.block-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.panel-heading > div,
.section-heading > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.panel h2 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.panel-note {
  font-size: 0.85rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Progress Panel */
.progress-panel {
  padding: var(--space-lg);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-md);
}

.metric-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  padding: var(--space-lg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.6);
}

.metric-card span {
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
}

.metric-card strong {
  font-size: 1.75rem;
  font-weight: 800;
  line-height: 1;
}

.metric-card.ink {
  background: rgba(16, 42, 67, 0.05);
  strong { color: var(--ink); }
}

.metric-card.teal {
  background: rgba(47, 125, 116, 0.08);
  strong { color: var(--teal); }
}

.metric-card.gold {
  background: rgba(217, 130, 43, 0.08);
  strong { color: var(--gold); }
}

.metric-card.coral {
  background: rgba(178, 58, 72, 0.08);
  strong { color: var(--coral); }
}

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-lg);
}

.card {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-lg);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--teal), var(--gold));
  opacity: 0;
  transition: opacity var(--transition);
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--line-teal);
  box-shadow: var(--shadow-hover);
}

.card:hover::before {
  opacity: 1;
}

.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
}

.card-menu-btn {
  background: transparent;
  border: none;
  padding: var(--space-xs);
  cursor: pointer;
  border-radius: var(--radius-full);
  color: var(--muted);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  min-height: 32px;
  box-shadow: none;
}

.card-menu-btn:hover {
  background: rgba(16, 42, 67, 0.08);
  color: var(--ink);
  transform: none;
  box-shadow: none;
}

.card-menu-dropdown {
  position: fixed;
  z-index: 1000;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  padding: var(--space-xs);
  animation: menuFadeIn 150ms ease;
}

@keyframes menuFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--ink);
  transition: background var(--transition);
  text-align: left;
  box-shadow: none;
}

.card-menu-item:hover {
  background: rgba(16, 42, 67, 0.06);
  transform: none;
  box-shadow: none;
}

.card-menu-item.danger {
  color: var(--coral);
}

.card-menu-item.danger:hover {
  background: rgba(178, 58, 72, 0.08);
}

.card h3 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
  word-break: break-word;
  font-family: var(--font-mono);
  color: var(--ink);
  padding: var(--space-sm);
  background: rgba(16, 42, 67, 0.03);
  border-radius: var(--radius-sm);
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--teal);
}

.risk {
  padding: 5px 10px;
  border-radius: var(--radius-full);
  background: rgba(16, 42, 67, 0.06);
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.risk-high {
  color: var(--coral);
  background: rgba(178, 58, 72, 0.1);
}

.snippet-list {
  margin: 0;
  padding-left: var(--space-md);
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.85rem;
}

.snippet-list li {
  margin-bottom: 4px;
}

.card footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-sm);
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid var(--line);
}

.card-score {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: rgba(16, 42, 67, 0.05);
}

/* Study plan card variant */
.study-plan-card {
  background: linear-gradient(135deg, rgba(47, 125, 116, 0.04), var(--surface));
  border-color: rgba(47, 125, 116, 0.15);
}

.study-plan-card::before {
  background: linear-gradient(90deg, var(--teal), var(--gold));
}

/* ========================================
   User Menu
   ======================================== */
.user-menu {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  z-index: 50;
}

.hero-copy {
  position: relative;
}

.user-menu-trigger {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md) var(--space-xs) var(--space-sm);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.user-menu-trigger:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow);
}

.user-menu-name {
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 260px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-md);
  animation: menuFadeIn 150ms ease;
}

.user-menu-info {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding-bottom: var(--space-md);
}

.user-menu-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(47, 125, 116, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--teal);
  flex-shrink: 0;
}

.user-menu-display-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
}

.user-menu-email {
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 2px;
}

.user-menu-role {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: rgba(47, 125, 116, 0.1);
  color: var(--teal);
  font-weight: 600;
  margin-top: 4px;
  display: inline-block;
}

.user-menu-divider {
  height: 1px;
  background: var(--line);
  margin: var(--space-sm) 0;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-xs);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--ink);
  transition: background var(--transition);
  text-align: left;
}

.user-menu-item:hover {
  background: rgba(16, 42, 67, 0.05);
}

.user-menu-item svg {
  flex-shrink: 0;
}

/* ========================================
   Components: Custom Select Dropdown
   ======================================== */
.custom-select-wrapper {
  position: relative;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.95rem;
  color: var(--ink);
  user-select: none;
}

.custom-select-trigger:hover {
  border-color: rgba(47, 125, 116, 0.3);
  background: rgba(255, 255, 255, 0.95);
}

.custom-select-trigger.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 125, 116, 0.1);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.custom-select-placeholder {
  color: var(--muted-light);
}

.custom-select-value {
  font-weight: 500;
  color: var(--ink);
}

.custom-select-arrow {
  transition: transform var(--transition);
  flex-shrink: 0;
  color: var(--muted);
}

.custom-select-trigger.active .custom-select-arrow {
  transform: rotate(180deg);
}

.custom-select-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 100;
  max-height: 360px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-top: none;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
  background: rgba(255, 252, 248, 0.98);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  animation: dropdownSlideIn 150ms ease;
}

@keyframes dropdownSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.custom-select-dropdown::-webkit-scrollbar {
  width: 6px;
}

.custom-select-dropdown::-webkit-scrollbar-track {
  background: transparent;
}

.custom-select-dropdown::-webkit-scrollbar-thumb {
  background: rgba(16, 42, 67, 0.15);
  border-radius: 3px;
}

.custom-select-dropdown::-webkit-scrollbar-thumb:hover {
  background: rgba(16, 42, 67, 0.25);
}

.select-group {
  border-bottom: 1px solid var(--line);
}

.select-group:last-child {
  border-bottom: none;
}

.select-group-title {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted-light);
  background: rgba(16, 42, 67, 0.03);
  user-select: none;
  position: sticky;
  top: 0;
  z-index: 1;
}

.select-option {
  padding: var(--space-sm) var(--space-md) var(--space-sm) calc(var(--space-md) + 6px);
  font-size: 0.9rem;
  color: var(--ink);
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.select-option:hover {
  background: rgba(47, 125, 116, 0.06);
  color: var(--teal);
}

.select-option.selected {
  background: rgba(47, 125, 116, 0.1);
  color: var(--teal);
  font-weight: 600;
}

.select-option.selected::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--teal);
  border-radius: 0 2px 2px 0;
}

.select-option-custom {
  font-weight: 600;
  color: var(--gold);
}

.select-option-custom:hover {
  color: var(--gold);
  background: rgba(217, 130, 43, 0.08);
}

/* ========================================
   Components: Forms & Inputs
   ======================================== */
textarea,
input[type="text"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: var(--space-md);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.85);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all var(--transition);
}

textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 125, 116, 0.1);
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 200px;
  line-height: 1.6;
}

textarea::placeholder,
input::placeholder {
  color: var(--muted-light);
}

/* Form Layouts */
.import-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.import-form textarea {
  min-height: 240px;
}

.plan-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.plan-form textarea {
  min-height: 100px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.field span {
  font-size: 0.9rem;
  color: var(--muted);
  font-weight: 500;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-md);
}

.field-full {
  grid-column: 1 / -1;
}

.config-form,
.quiz-form,
.mode-panels {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.config-subpanel {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius);
  background: var(--surface-strong);
  border: 1px solid var(--line);
}

.subpanel-head {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.subpanel-head h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.subpanel-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ========================================
   Components: Buttons
   ======================================== */
button {
  border: none;
  border-radius: var(--radius-full);
  padding: var(--space-sm) var(--space-lg);
  background: var(--ink);
  color: #fff;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
  background: var(--ink-light);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.ghost-button {
  background: rgba(16, 42, 67, 0.08);
  color: var(--ink);
}

.ghost-button:hover {
  background: rgba(16, 42, 67, 0.12);
  box-shadow: none;
}

.admin-link {
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-full);
  background: rgba(16, 42, 67, 0.06);
  font-size: 0.85rem;
  font-weight: 600;
  transition: all var(--transition);
}

.admin-link:hover {
  background: rgba(16, 42, 67, 0.1);
  color: var(--ink);
}

/* Button Groups */
.import-actions,
.detail-actions,
.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  align-items: center;
}

.import-actions {
  justify-content: space-between;
}

.detail-actions {
  justify-content: flex-start;
}

/* ========================================
   Components: Chat & Quiz
   ======================================== */
.chat-panel,
.quiz-panel,
.detail-panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  max-height: 500px;
  overflow-y: auto;
  padding-right: var(--space-xs);
}

.chat-bubble {
  padding: var(--space-md);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
}

.chat-bubble.user {
  background: rgba(16, 42, 67, 0.06);
}

.chat-bubble.assistant {
  background: rgba(47, 125, 116, 0.06);
}

.chat-bubble.streaming {
  border: 1px dashed rgba(47, 125, 116, 0.4);
  background: rgba(47, 125, 116, 0.04);
}

.role {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: var(--space-xs);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bubble-body {
  line-height: 1.7;
  font-size: 0.95rem;
}

.bubble-body p {
  margin: 0;
}

.bubble-body p + p {
  margin-top: var(--space-sm);
}

/* Quiz */
.quiz-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.quiz-option {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  padding: var(--space-md);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(16, 42, 67, 0.03);
  cursor: pointer;
  transition: all var(--transition);
}

.quiz-option:hover {
  background: rgba(47, 125, 116, 0.06);
  border-color: var(--line-teal);
}

.quiz-option input[type="radio"] {
  width: auto;
  margin-top: 4px;
  flex-shrink: 0;
}

.quiz-result {
  margin-top: var(--space-sm);
  padding: var(--space-md);
  border-radius: var(--radius);
  line-height: 1.6;
}

.quiz-result.correct {
  background: rgba(47, 125, 116, 0.12);
  color: var(--teal);
}

.quiz-result.incorrect {
  background: rgba(178, 58, 72, 0.1);
  color: var(--coral);
}

/* ========================================
   Detail Page Layout
   ======================================== */
.shell.shell-detail-shell {
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 0;
  height: 100vh;
  overflow: hidden;
}

.detail-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  height: 100vh;
  width: 100%;
  overflow: hidden;
}

/* Sidebar - Original Style */
.shell-detail-shell .detail-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-right: 1px solid var(--line);
  height: 100%;
  overflow: hidden;
  min-width: 260px;
  max-width: 260px;
}

.sidebar-header {
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  background: rgba(255,252,248,0.98);
}

.sidebar-back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
  transition: color var(--transition);
}

.sidebar-back-link:hover {
  color: var(--teal);
}

.sidebar-back-link svg {
  width: 14px;
  height: 14px;
}

#detail-plan-title {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-list-sidebar {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-xs);
  background: var(--bg);
}

.task-list-sidebar::-webkit-scrollbar {
  width: 4px;
}

.task-list-sidebar::-webkit-scrollbar-thumb {
  background: rgba(16,42,67,0.12);
  border-radius: 2px;
}

/* Task Items - Collapsible Days */
.task-list-sidebar .task-day {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: var(--space-xs);
  background: rgba(255,255,255,0.7);
  overflow: hidden;
  transition: border-color var(--transition);
}

.task-list-sidebar .task-day:hover {
  border-color: rgba(47,125,116,0.2);
}

.task-list-sidebar .task-day.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 1px rgba(47,125,116,0.08);
}

.task-list-sidebar .day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  gap: 8px;
  background: transparent;
  transition: background var(--transition);
  user-select: none;
}

.task-list-sidebar .day-header:hover {
  background: rgba(47,125,116,0.04);
}

.task-list-sidebar .day-header > div {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.task-list-sidebar .day-header .toggle-icon {
  width: 14px;
  height: 14px;
  color: var(--muted);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.task-list-sidebar .task-day.active .day-header .toggle-icon {
  transform: rotate(180deg);
}

.task-list-sidebar .day-number {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--teal);
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(47,125,116,0.08);
  white-space: nowrap;
  flex-shrink: 0;
}

.task-list-sidebar .day-title {
  font-weight: 600;
  font-size: 0.82rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-list-sidebar .day-commands {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 0 10px 10px;
  animation: slideDown 200ms ease;
}

@keyframes slideDown {
  from { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; }
  to { opacity: 1; max-height: 800px; padding-top: 0; padding-bottom: 10px; }
}

.task-list-sidebar .command-item {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255,255,255,0.8);
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: 4px;
}

.task-list-sidebar .command-item:hover {
  background: rgba(47,125,116,0.04);
  border-color: rgba(47,125,116,0.15);
}

.task-list-sidebar .command-item.completed {
  background: rgba(47,125,116,0.06);
  border-color: rgba(47,125,116,0.15);
}

.task-list-sidebar .command-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.task-list-sidebar .command-text {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-list-sidebar .command-status {
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--teal);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: var(--space-xs);
}

.task-list-sidebar .command-desc {
  color: var(--muted);
  font-size: 0.68rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-list-sidebar .command-actions {
  display: flex;
  gap: 4px;
}

.task-list-sidebar .command-actions .ghost-button {
  padding: 3px 8px;
  font-size: 0.62rem;
  border-radius: 999px;
  background: rgba(16,42,67,0.06);
  color: var(--ink);
  border: none;
}

.task-list-sidebar .command-actions .ghost-button:hover {
  background: rgba(47,125,116,0.1);
  color: var(--teal);
}

/* Chat Main */
.shell-detail-shell .detail-main {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at top right, rgba(217, 130, 43, 0.04), transparent 24%),
    radial-gradient(circle at bottom left, rgba(47, 125, 116, 0.04), transparent 22%),
    var(--bg);
  gap: 0;
}

.chat-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  position: relative;
  min-width: 0;
}

.chat-main .chat-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  overflow: hidden;
}

/* Chat Messages Area */
.chat-main .chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 0;
  display: flex;
  flex-direction: column;
  scroll-behavior: smooth;
}

.chat-main .chat-log::-webkit-scrollbar {
  width: 6px;
}

.chat-main .chat-log::-webkit-scrollbar-thumb {
  background: rgba(16, 42, 67, 0.1);
  border-radius: 3px;
}

/* Welcome Screen */
.chat-welcome {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-2xl) var(--space-xl);
  text-align: center;
  gap: var(--space-md);
}

.chat-welcome-icon {
  color: var(--muted);
  margin-bottom: var(--space-sm);
}

.chat-welcome h3 {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}

.chat-welcome p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 400px;
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: center;
  margin-top: var(--space-md);
}

.suggestion-btn {
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--line);
  border-radius: var(--radius-full);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.suggestion-btn:hover {
  border-color: var(--teal);
  background: rgba(47, 125, 116, 0.05);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Chat Bubbles - ChatGPT Clean Style */
.chat-bubble {
  padding: 0;
  animation: bubbleFadeIn 200ms ease;
  border-bottom: 1px solid rgba(16,42,67,0.04);
}

.chat-bubble:last-child {
  border-bottom: none;
}

.chat-bubble.assistant,
.chat-bubble.streaming {
  background: transparent;
}

.chat-bubble.user {
  background: rgba(16,42,67,0.02);
}

@keyframes bubbleFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.bubble-content {
  flex: 1;
  min-width: 0;
  max-width: 768px;
  margin: 0 auto;
  padding: var(--space-md) var(--space-xl);
}

.chat-bubble.user .bubble-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.bubble-body {
  min-height: 1.5em;
  line-height: 1.75;
  font-size: 0.95rem;
  color: var(--ink);
}

.chat-bubble.user .bubble-body {
  background: rgba(16,42,67,0.08);
  color: var(--ink);
  padding: 10px 16px;
  border-radius: 18px 18px 4px 18px;
  display: inline-block;
  max-width: 85%;
  line-height: 1.6;
}

.chat-bubble.user .bubble-body code {
  background: rgba(16,42,67,0.12);
  color: var(--ink);
  padding: 2px 5px;
  border-radius: 4px;
}

.chat-bubble.assistant .bubble-body,
.chat-bubble.streaming .bubble-body {
  padding: 8px 0;
}

.bubble-body code {
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(16, 42, 67, 0.06);
  font-family: var(--font-mono);
  font-size: 0.88em;
  color: var(--teal);
}

.bubble-body pre {
  background: rgba(16, 42, 67, 0.04);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  overflow-x: auto;
  margin: var(--space-sm) 0;
}

.bubble-body pre code {
  background: transparent;
  padding: 0;
  font-size: 0.85rem;
  color: var(--ink);
}

.bubble-body h1,
.bubble-body h2,
.bubble-body h3 {
  margin: var(--space-md) 0 var(--space-sm);
  font-weight: 700;
}

.bubble-body h1 { font-size: 1.3em; }
.bubble-body h2 { font-size: 1.15em; }
.bubble-body h3 { font-size: 1.05em; }

.bubble-body li {
  margin-left: var(--space-md);
  list-style: disc;
}

.bubble-body p {
  margin: 0;
}

.bubble-body p + p {
  margin-top: var(--space-sm);
}

/* Floating Input Bar - ChatGPT Style */
.chat-main .chat-form {
  padding: var(--space-md) var(--space-xl) var(--space-lg);
  background: transparent;
  border-top: none;
  position: relative;
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: var(--space-xs);
  max-width: 720px;
  margin: 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-sm);
  box-shadow: var(--shadow);
  transition: all var(--transition);
}

.chat-input-wrapper:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(47, 125, 116, 0.1), var(--shadow);
}

.quiz-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  background: rgba(217, 130, 43, 0.1);
  color: var(--gold);
  flex-shrink: 0;
}

.quiz-btn:hover {
  background: rgba(217, 130, 43, 0.2);
  transform: none;
  box-shadow: none;
}

/* Quiz Card Styles */
.quiz-card {
  background: rgba(255, 252, 248, 0.95);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
}

.quiz-card-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--line);
  color: var(--gold);
  font-weight: 700;
  font-size: 1rem;
}

.quiz-question {
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px dashed var(--line);
}

.quiz-question:last-of-type {
  border-bottom: none;
}

.quiz-question-text {
  font-weight: 600;
  margin-bottom: var(--space-sm);
  font-size: 0.95rem;
  line-height: 1.5;
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  margin-bottom: var(--space-sm);
}

.quiz-option-btn {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.8);
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  font-size: 0.9rem;
}

.quiz-option-btn:hover:not(:disabled) {
  background: rgba(47, 125, 116, 0.05);
  border-color: var(--teal);
}

.quiz-option-btn.selected {
  background: rgba(47, 125, 116, 0.1);
  border-color: var(--teal);
  color: var(--teal);
  font-weight: 600;
}

.quiz-option-btn.correct-answer {
  background: rgba(47, 125, 116, 0.15);
  border-color: var(--teal);
  color: var(--teal);
}

.quiz-option-btn.wrong-answer {
  background: rgba(178, 58, 72, 0.1);
  border-color: var(--coral);
  color: var(--coral);
}

.quiz-option-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.quiz-option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(16, 42, 67, 0.06);
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.quiz-option-btn.selected .quiz-option-letter {
  background: var(--teal);
  color: #fff;
}

.quiz-option-btn.correct-answer .quiz-option-letter {
  background: var(--teal);
  color: #fff;
}

.quiz-option-btn.wrong-answer .quiz-option-letter {
  background: var(--coral);
  color: #fff;
}

.quiz-question-actions {
  margin-top: var(--space-xs);
}

.quiz-submit-btn {
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.quiz-submit-btn:hover:not(:disabled) {
  background: #246b63;
  transform: translateY(-1px);
}

.quiz-submit-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.quiz-result {
  margin-top: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  font-size: 0.85rem;
  line-height: 1.6;
}

.quiz-result.correct {
  background: rgba(47, 125, 116, 0.1);
  border: 1px solid rgba(47, 125, 116, 0.2);
}

.quiz-result.incorrect {
  background: rgba(178, 58, 72, 0.08);
  border: 1px solid rgba(178, 58, 72, 0.15);
}

.quiz-result-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.quiz-result-text strong {
  display: block;
  margin-bottom: 2px;
}

.quiz-result-text p {
  margin: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.quiz-card-footer {
  margin-top: var(--space-md);
  padding-top: var(--space-md);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
}

.quiz-grade-btn {
  padding: var(--space-sm) var(--space-xl);
  border-radius: var(--radius-full);
  border: none;
  background: var(--ink);
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.quiz-grade-btn:hover {
  background: var(--ink-light);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.quiz-score {
  text-align: center;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--teal);
  padding: var(--space-md);
}

.chat-input-wrapper textarea {
  flex: 1;
  border: none;
  background: transparent;
  padding: var(--space-xs) var(--space-sm);
  font-size: 0.95rem;
  line-height: 1.5;
  resize: none;
  max-height: 150px;
  min-height: 24px;
}

.chat-input-wrapper textarea:focus {
  outline: none;
  box-shadow: none;
}

.chat-input-actions {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.chat-input-actions button {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--ink);
  color: #fff;
}

.chat-input-actions button:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  opacity: 0.85;
}

.chat-input-actions button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.stop-btn {
  width: auto !important;
  padding: 0 var(--space-md) !important;
  gap: var(--space-xs);
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--coral) !important;
}

.stop-btn svg {
  width: 14px;
  height: 14px;
}

/* Cursor Blink */
.cursor-blink {
  animation: blink 1s step-end infinite;
  color: var(--teal);
  font-size: 0.8em;
}

@keyframes blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* Plan Summary */
.plan-summary {
  margin: var(--space-md) 0 var(--space-sm);
  padding: var(--space-sm);
  background: rgba(16, 42, 67, 0.03);
  border-radius: var(--radius-sm);
}

.plan-meta {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.plan-meta span {
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  background: rgba(16, 42, 67, 0.06);
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
}

/* Responsive Detail */
@media (max-width: 900px) {
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .detail-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 85%);
    z-index: 100;
    transform: translateX(-100%);
    transition: transform var(--transition);
    box-shadow: var(--shadow-lg);
  }

  .detail-sidebar.open {
    transform: translateX(0);
  }

  .detail-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(16, 42, 67, 0.5);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
  }

  .detail-sidebar-overlay.open {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ========================================
   Components: Study Plan
   ======================================== */
.study-plan-card {
  background: linear-gradient(135deg, rgba(47, 125, 116, 0.05), rgba(255, 255, 255, 0.78));
  border-color: rgba(47, 125, 116, 0.2);
}

/* Detail Task List (Sidebar) */
.task-list-sidebar .task-day {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: var(--space-xs);
  transition: all var(--transition);
  background: rgba(255, 255, 255, 0.7);
}

.task-list-sidebar .task-day:hover {
  border-color: rgba(47, 125, 116, 0.15);
}

.task-list-sidebar .task-day.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 1px rgba(47, 125, 116, 0.08);
  background: rgba(47, 125, 116, 0.02);
}

.task-list-sidebar .day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm);
  cursor: pointer;
  transition: background var(--transition);
  gap: var(--space-xs);
}

.task-list-sidebar .day-header:hover {
  background: rgba(16, 42, 67, 0.03);
}

.task-list-sidebar .day-header > div {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-width: 0;
  flex: 1;
}

.task-list-sidebar .day-number {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--teal);
  padding: 3px 6px;
  border-radius: var(--radius-full);
  background: rgba(47, 125, 116, 0.08);
  white-space: nowrap;
  flex-shrink: 0;
}

.task-list-sidebar .day-title {
  font-weight: 600;
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-list-sidebar .day-commands {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 var(--space-sm) var(--space-sm);
  animation: slideDown 150ms ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 800px;
  }
}

.task-list-sidebar .command-item {
  padding: 6px var(--space-xs);
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  transition: all var(--transition);
  cursor: pointer;
}

.task-list-sidebar .command-item:hover {
  background: rgba(47, 125, 116, 0.04);
  border-color: rgba(47, 125, 116, 0.1);
}

.task-list-sidebar .command-item.completed {
  background: rgba(47, 125, 116, 0.05);
}

.task-list-sidebar .command-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.task-list-sidebar .command-text {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-list-sidebar .command-status {
  font-size: 0.68rem;
  font-weight: 600;
  color: var(--muted-light);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: var(--space-xs);
}

.task-list-sidebar .command-item.completed .command-status {
  color: var(--teal);
}

.task-list-sidebar .command-desc {
  color: var(--muted);
  font-size: 0.72rem;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-list-sidebar .command-actions {
  display: flex;
  gap: 4px;
}

.task-list-sidebar .command-actions .ghost-button {
  padding: 3px 8px;
  font-size: 0.68rem;
  border-radius: 999px;
}

/* Plan Summary */
.plan-summary {
  margin: var(--space-md) 0;
}

.plan-meta {
  display: flex;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.plan-meta span {
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  background: rgba(16, 42, 67, 0.06);
  font-size: 0.85rem;
  font-weight: 500;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: var(--space-md);
}

.task-day {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  transition: all var(--transition);
}

.task-day.active {
  border-color: var(--teal);
  box-shadow: 0 0 0 2px rgba(47, 125, 116, 0.1);
}

.day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-md);
  background: rgba(16, 42, 67, 0.03);
  cursor: pointer;
  transition: background var(--transition);
}

.day-header:hover {
  background: rgba(16, 42, 67, 0.06);
}

.day-header > div {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.day-number {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--teal);
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-full);
  background: rgba(47, 125, 116, 0.1);
}

.day-title {
  font-weight: 600;
  font-size: 1rem;
}

.day-category {
  font-size: 0.8rem;
  color: var(--muted);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  background: rgba(16, 42, 67, 0.05);
}

.day-commands {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding: var(--space-md);
  animation: slideDown 200ms ease;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
  }
  to {
    opacity: 1;
    max-height: 1000px;
  }
}

.command-item {
  padding: var(--space-md);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.6);
  transition: all var(--transition);
}

.command-item.completed {
  background: rgba(47, 125, 116, 0.05);
  border-color: rgba(47, 125, 116, 0.2);
}

.command-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-xs);
}

.command-text {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--ink);
}

.command-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}

.command-item.completed .command-status {
  color: var(--teal);
}

.command-desc {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: var(--space-sm);
}

.command-actions {
  display: flex;
  gap: var(--space-sm);
}

.command-actions .ghost-button {
  padding: var(--space-xs) var(--space-md);
  font-size: 0.8rem;
}

/* ========================================
   Components: Detail Page
   ======================================== */
.hero-detail {
  grid-template-columns: minmax(0, 1.3fr) minmax(340px, 0.7fr);
}

.detail-main .chat-panel {
  min-height: 600px;
}

.detail-main .chat-log {
  min-height: 400px;
  max-height: 600px;
}

.command-hero {
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius);
  background: rgba(16, 42, 67, 0.04);
  border: 1px dashed var(--line-strong);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.6;
  word-break: break-all;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-grid > div {
  padding: var(--space-md);
  border-radius: var(--radius);
  background: rgba(16, 42, 67, 0.04);
}

.detail-grid dt {
  margin-bottom: var(--space-xs);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.detail-grid dd {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
}

/* ========================================
   Components: Modal
   ======================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 42, 67, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  z-index: 1000;
  animation: fadeIn 200ms ease;
}

.modal-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-content {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xl);
  animation: slideUp 300ms ease;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
}

/* ========================================
   Components: Empty State
   ======================================== */
.empty-state {
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  text-align: center;
  padding: var(--space-xl);
}

.empty-state h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

/* ========================================
   Utilities
   ======================================== */
.icon {
  width: 1.1rem;
  height: 1.1rem;
  vertical-align: -0.15rem;
  margin-right: var(--space-xs);
}

.card-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 20px;
  border-radius: 9999px;
  background: var(--teal);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  text-decoration: none;
  transition: all var(--transition);
  white-space: nowrap;
}

.card-link:hover {
  background: #246b63;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(47, 125, 116, 0.3);
  color: #fff;
  text-decoration: none;
}

.card-link:active {
  transform: translateY(0);
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 1280px) {
  .app-layout,
  .detail-layout,
  .admin-layout,
  .hero-app,
  .hero-admin,
  .hero-detail {
    grid-template-columns: 1fr;
  }

  .sidebar-stack,
  .detail-side,
  .admin-side {
    position: static;
    max-height: none;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 768px) {
  :root {
    --space-xl: 24px;
    --space-lg: 18px;
  }

  .shell:not(.shell-detail-shell) {
    width: calc(100% - 32px);
    margin: var(--space-lg) auto var(--space-xl);
  }

  .hero {
    padding: var(--space-lg);
    border-radius: var(--radius-xl);
  }

  .hero strong {
    max-width: none;
    font-size: 1.75rem;
  }

  .hero h1 {
    font-size: 1.5rem;
  }

  .panel {
    padding: var(--space-md);
    border-radius: var(--radius);
  }

  .modal-overlay {
    padding: var(--space-md);
    align-items: flex-end;
  }

  .modal-content {
    width: 100%;
    max-height: 85vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .card-head,
  .card footer,
  .section-heading,
  .panel-heading,
  .block-heading {
    flex-direction: column;
    align-items: flex-start;
  }

  .import-actions {
    flex-direction: column;
  }

  .import-actions button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .shell:not(.shell-detail-shell) {
    width: calc(100% - 24px);
    margin: var(--space-md) auto;
  }

  .hero-badges {
    gap: var(--space-xs);
  }

  .hero-badges span {
    font-size: 0.75rem;
    padding: 6px 10px;
  }

  button {
    padding: var(--space-sm) var(--space-md);
    font-size: 0.85rem;
  }

  .brand svg {
    width: 44px;
    height: 44px;
  }
}
