@property --fade-start {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

@property --fade-end {
  syntax: "<length>";
  inherits: false;
  initial-value: 0px;
}

:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-alt: #f8fafc;
  --surface-tint: #eef3fb;
  --text: #0f172a;
  --text-muted: #475569;
  --border: #cbd5e1;
  --accent: #1d4ed8;
  --accent-hover: #1e40af;
  --accent-soft: #dbeafe;
  --navy: #1f3864;
  --emerald: #047857;
  --emerald-soft: #d1fae5;
  --amber: #b45309;
  --amber-soft: #fef3c7;
  --rose: #be123c;
  --rose-soft: #ffe4e6;
  --purple: #6d28d9;
  --purple-soft: #ede9fe;
  --radius: 12px;
  --shadow: 0 2px 10px rgb(15 23 42 / 0.06);
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  font-size: 0.95rem;
}

/* Topbar */
.topbar {
  background: var(--navy);
  color: #fff;
  padding: 0.85rem 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-block-end: 1px solid rgb(255 255 255 / 0.14);
}

.brand-group {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.brand-eyebrow {
  font-size: 0.76rem;
  letter-spacing: 0.03em;
  color: #93c5fd;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.brand-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
}

.topbar-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.edge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgb(16 185 129 / 0.18);
  border: 1px solid rgb(52 211 153 / 0.45);
  color: #a7f3d0;
  font-size: 0.76rem;
  font-weight: 600;
}

.edge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #34d399;
}

.role-select {
  background: rgb(255 255 255 / 0.12);
  color: #fff;
  border: 1px solid rgb(255 255 255 / 0.28);
  border-radius: 8px;
  padding: 0.35rem 0.6rem;
  font-size: 0.82rem;
}

.role-select option {
  color: #0f172a;
  background: #fff;
}

.lang-btn {
  background: #fff;
  color: var(--navy);
  border: none;
  border-radius: 8px;
  padding: 0.38rem 0.75rem;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.lang-btn:hover {
  background: #e2e8f0;
}

/* Main container & Tabs following modern-web-guidance `tabs` */
.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
}

.tabs {
  display: grid;
  grid-template-rows: auto 1fr;
}

.tablist {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: inline proximity;
  scroll-padding-inline: 3rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding-inline: 0.5rem;
  --fade-size: 3rem;
  --fade-dir: right;
  --fade-start-pos: 0;
  --fade-end-pos: 100%;
  mask:
    linear-gradient(black, black) no-clip subtract,
    linear-gradient(to var(--fade-dir), black, transparent) var(--fade-start-pos) 0 / var(--fade-start) 100% no-repeat no-clip,
    linear-gradient(to var(--fade-dir), transparent, black) var(--fade-end-pos) 0 / var(--fade-end) 100% no-repeat no-clip;
  animation: reveal-fade-start linear both, hide-fade-end linear both;
  animation-timeline: scroll(self inline);
  animation-range: 0 var(--fade-size), calc(100% - var(--fade-size)) 100%;
}

@keyframes reveal-fade-start {
  to { --fade-start: var(--fade-size); }
}

@keyframes hide-fade-end {
  from { --fade-end: var(--fade-size); }
}

.tablist button {
  flex: none;
  scroll-snap-align: start;
  position: relative;
  appearance: none;
  background: transparent;
  border: none;
  padding: 0.85rem 1.15rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.tablist button:hover {
  color: var(--text);
}

.tablist button[aria-selected="true"] {
  color: var(--accent);
}

.tablist button[aria-selected="true"]::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  border-block-end: 3px solid var(--accent);
}

.panels-stack {
  display: grid;
}

/* All panels share the same grid cell; styles live on .panel-inner, never on [role="tabpanel"] */
[role="tabpanel"] {
  grid-area: 1 / 1;
}

.panel-inner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-block-start: none;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* Practice Space 3-Column Layout */
.practice-grid {
  display: grid;
  grid-template-columns: 310px 1fr 340px;
  gap: 1.15rem;
  align-items: start;
}

@media (max-width: 1180px) {
  .practice-grid {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-block-end: 0.75rem;
}

.card-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--navy);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 600;
}

.badge-blue { background: var(--accent-soft); color: var(--accent); }
.badge-green { background: var(--emerald-soft); color: var(--emerald); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-rose { background: var(--rose-soft); color: var(--rose); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }

/* Profile Form Controls */
.field-group {
  margin-block-end: 0.75rem;
}

.field-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-block-end: 0.28rem;
}

.field-select, .field-input, .field-textarea {
  width: 100%;
  padding: 0.48rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  font-size: 0.86rem;
  color: var(--text);
  font-family: inherit;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
  font-family: inherit;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-outline {
  background: #fff;
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--surface-tint);
}

.btn-emerald {
  background: var(--emerald);
  color: #fff;
}

.btn-block {
  width: 100%;
}

/* Video-Call Stage */
.video-stage {
  background: #0f172a;
  color: #fff;
  border-radius: 12px;
  padding: 1rem;
  position: relative;
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 1rem;
  align-items: center;
  margin-block-end: 0.85rem;
}

@media (max-width: 680px) {
  .video-stage {
    grid-template-columns: 1fr;
  }
}

.avatar-frame {
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 2px solid #334155;
  border-radius: 12px;
  padding: 0.65rem;
  text-align: center;
  position: relative;
}

.avatar-frame.speaking {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgb(56 189 248 / 0.25);
}

.avatar-svg {
  width: 120px;
  height: 120px;
  display: block;
  margin: 0 auto;
}

.waveform {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 3px;
  height: 16px;
  margin-block-start: 0.35rem;
}

.wave-bar {
  width: 3px;
  height: 5px;
  background: #38bdf8;
  border-radius: 2px;
  transition: height 0.15s ease;
}

.avatar-frame.speaking .wave-bar:nth-child(1) { height: 12px; }
.avatar-frame.speaking .wave-bar:nth-child(2) { height: 16px; }
.avatar-frame.speaking .wave-bar:nth-child(3) { height: 9px; }
.avatar-frame.speaking .wave-bar:nth-child(4) { height: 15px; }
.avatar-frame.speaking .wave-bar:nth-child(5) { height: 10px; }

.learner-telemetry {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.learner-name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.learner-name {
  font-size: 1.08rem;
  font-weight: 700;
}

.state-box {
  background: rgb(255 255 255 / 0.07);
  border: 1px solid rgb(255 255 255 / 0.15);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font-size: 0.83rem;
}

/* Lyster & Ranta Sequence Tracker */
.sequence-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.45rem;
  margin-block-end: 0.85rem;
}

@media (max-width: 680px) {
  .sequence-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

.seq-step {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
  font-size: 0.78rem;
}

.seq-step.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.seq-step-title {
  font-weight: 700;
  color: var(--navy);
  display: block;
}

.seq-step-val {
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Transcript */
.chat-transcript {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.9rem;
  max-height: 360px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-block-end: 0.85rem;
}

.turn-bubble {
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  max-width: 92%;
  border: 1px solid var(--border);
}

.turn-learner {
  align-self: flex-start;
  background: #f8fafc;
  border-inline-start: 4px solid #0284c7;
}

.turn-tutor {
  align-self: flex-end;
  background: #eff6ff;
  border-inline-end: 4px solid var(--accent);
}

.turn-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.74rem;
  color: var(--text-muted);
  margin-block-end: 0.3rem;
}

.error-highlight {
  background: #fee2e2;
  color: #991b1b;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  font-weight: 600;
  text-decoration: underline wavy #dc2626;
}

.repair-highlight {
  background: #d1fae5;
  color: #065f46;
  padding: 0.05rem 0.3rem;
  border-radius: 4px;
  font-weight: 600;
}

/* Quick-Try SLA Move Chips */
.move-chips {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 0.45rem;
  margin-block-end: 0.75rem;
}

.move-chip {
  text-align: left;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.45rem 0.65rem;
  cursor: pointer;
  font-size: 0.78rem;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s;
}

.move-chip:hover {
  border-color: var(--accent);
  background: var(--surface-tint);
}

.move-chip strong {
  display: block;
  color: var(--navy);
  font-size: 0.8rem;
}

.move-chip span {
  color: var(--text-muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-row {
  display: flex;
  gap: 0.5rem;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-block-end: 1.15rem;
}

@media (max-width: 900px) {
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.metric-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}

.metric-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.metric-value {
  font-size: 1.45rem;
  font-weight: 800;
  color: var(--navy);
  margin: 0.2rem 0;
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Responsive Data Table following modern-web-guidance `responsive-table` */
.table-wrapper {
  overflow: auto;
  max-inline-size: 100%;
  max-block-size: min(540px, 80vh);
  container-type: inline-size;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  margin-block-end: 1rem;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.85rem;
}

caption {
  text-align: left;
  padding: 0.65rem 0.85rem;
  font-weight: 700;
  color: var(--navy);
  background: var(--surface-tint);
  border-block-end: 1px solid var(--border);
}

thead {
  position: sticky;
  inset-block-start: 0;
  z-index: 1;
}

thead th {
  background: #e2e8f0;
  color: var(--navy);
  font-weight: 700;
  text-align: left;
  padding: 0.6rem 0.75rem;
  border-block-end: 1px solid var(--border);
  white-space: nowrap;
}

tbody th, tbody td {
  padding: 0.6rem 0.75rem;
  border-block-end: 1px solid #e2e8f0;
  vertical-align: top;
  text-align: left;
}

tbody th {
  position: sticky;
  inset-inline-start: 0;
  background: var(--surface);
  font-weight: 700;
  color: var(--navy);
}

@container (width < 600px) {
  table, thead, tbody, tr, th, td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    margin-block-end: 1rem;
    border: 1px solid var(--border);
  }

  tbody th {
    position: sticky;
    inset-block-start: 0;
    z-index: 2;
    background: #f1f5f9;
  }

  td:nth-child(2)::before { content: var(--label-2) ": "; font-weight: 700; }
  td:nth-child(3)::before { content: var(--label-3) ": "; font-weight: 700; }
  td:nth-child(4)::before { content: var(--label-4) ": "; font-weight: 700; }
  td:nth-child(5)::before { content: var(--label-5) ": "; font-weight: 700; }
  td:nth-child(6)::before { content: var(--label-6) ": "; font-weight: 700; }
}
