:root {
  --tv-bg0: #13221e;
  --tv-bg1: #1c322c;
  --tv-surface: rgba(236, 243, 238, 0.06);
  --tv-border: rgba(210, 228, 216, 0.16);
  --tv-text: #e8f0ea;
  --tv-muted: #9bb5a8;
  --tv-accent: #6fbf9a;
  --tv-accent-2: #e0b35a;
  --tv-danger: #e07a6a;
  --tv-font-display: "Literata", Georgia, serif;
  --tv-font: "Manrope", system-ui, sans-serif;
}

* { box-sizing: border-box; }

.tv-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--tv-font);
  color: var(--tv-text);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(111, 191, 154, 0.22), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(224, 179, 90, 0.12), transparent 50%),
    linear-gradient(165deg, var(--tv-bg0), var(--tv-bg1) 45%, #0f1a17);
}

.tv-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}

.tv-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.tv-header-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.65rem;
}

.tv-header-side .lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.2rem;
  border-radius: 999px;
  border: 1px solid var(--tv-border);
  background: rgba(8, 16, 14, 0.35);
}

.tv-header-side .lang-btn {
  border: none;
  background: transparent;
  color: var(--tv-muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.5rem;
  border-radius: 999px;
  cursor: pointer;
}

.tv-header-side .lang-btn.active,
.tv-header-side .lang-btn[aria-pressed="true"] {
  color: #041206;
  background: var(--tv-accent);
}

.tv-tip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-left: 0.35rem;
  vertical-align: middle;
  border-radius: 50%;
  border: 1px solid rgba(224, 179, 90, 0.55);
  background: rgba(224, 179, 90, 0.12);
  color: var(--tv-accent-2);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  position: relative;
}

.tv-tip:hover,
.tv-tip:focus-visible {
  background: rgba(224, 179, 90, 0.22);
  outline: none;
}

.tv-tip::after {
  content: attr(title);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.45rem);
  transform: translateX(-50%);
  width: min(18rem, 70vw);
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  border: 1px solid var(--tv-border);
  background: #0f1a17;
  color: var(--tv-text);
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s;
  z-index: 40;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.35);
}

.tv-tip:hover::after,
.tv-tip:focus-visible::after {
  opacity: 1;
}

.tv-hint-warn {
  color: #f0c674 !important;
}

.tv-inline-link {
  color: var(--tv-accent);
  font-weight: 650;
  margin-left: 0.35rem;
}

.tv-nav a[hidden] {
  display: none !important;
}

.tv-auth-panel .tv-actions {
  margin-top: 0.65rem;
}


.tv-brand {
  margin: 0;
  font-family: var(--tv-font-display);
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--tv-accent);
  line-height: 1.1;
}

.tv-header h1 {
  margin: 0.25rem 0 0;
  font-family: var(--tv-font-display);
  font-size: clamp(1.15rem, 2.4vw, 1.45rem);
  font-weight: 500;
  color: var(--tv-text);
}

.tv-sub, .tv-hint {
  color: var(--tv-muted);
  font-size: 0.95rem;
  line-height: 1.45;
}

.tv-timer {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 0.55rem 0.85rem;
  border: 1px solid var(--tv-border);
  border-radius: 12px;
  background: var(--tv-surface);
  min-width: 5.5rem;
}

.tv-timer.is-urgent {
  border-color: rgba(224, 122, 106, 0.5);
  color: var(--tv-danger);
}

.tv-timer-val {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 1.25rem;
}

.tv-timer-label {
  font-size: 0.75rem;
  color: var(--tv-muted);
}

.tv-panel {
  background: var(--tv-surface);
  border: 1px solid var(--tv-border);
  border-radius: 16px;
  padding: 1.25rem 1.35rem;
  backdrop-filter: blur(8px);
}

.tv-layout {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1rem;
  align-items: start;
}

@media (max-width: 860px) {
  .tv-layout { grid-template-columns: 1fr; }
  .tv-header { flex-direction: column; }
}

.tv-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin: 0.85rem 0;
}

.tv-field span {
  font-size: 0.85rem;
  color: var(--tv-muted);
}

.tv-field input,
.tv-field textarea,
.tv-chat-form input {
  width: 100%;
  border: 1px solid var(--tv-border);
  border-radius: 10px;
  background: rgba(8, 16, 14, 0.45);
  color: var(--tv-text);
  padding: 0.7rem 0.85rem;
  font: inherit;
}

.tv-field textarea { resize: vertical; min-height: 110px; }

.tv-activity-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.85rem;
  margin-top: 1rem;
}

.tv-activity-card {
  text-align: left;
  border: 1px solid var(--tv-border);
  border-radius: 14px;
  background: rgba(8, 16, 14, 0.35);
  color: inherit;
  padding: 1rem 1.1rem;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.tv-activity-card:hover {
  border-color: rgba(111, 191, 154, 0.55);
  transform: translateY(-2px);
}

.tv-activity-kicker {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--tv-accent-2);
}

.tv-activity-card strong { font-size: 1.05rem; }
.tv-activity-card span:last-child { color: var(--tv-muted); font-size: 0.88rem; }

.tv-step-meta {
  margin: 0;
  color: var(--tv-accent);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tv-prompt {
  line-height: 1.5;
  color: var(--tv-text);
}

.tv-choices {
  display: grid;
  gap: 0.55rem;
  margin: 1rem 0;
}

.tv-choice {
  border: 1px solid var(--tv-border);
  border-radius: 12px;
  background: rgba(8, 16, 14, 0.4);
  color: inherit;
  padding: 0.75rem 0.9rem;
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.tv-choice.is-selected {
  border-color: var(--tv-accent);
  box-shadow: inset 0 0 0 1px rgba(111, 191, 154, 0.35);
}

.tv-choice[data-letter="D"] { border-left: 4px solid #c45c4a; }
.tv-choice[data-letter="I"] { border-left: 4px solid #d4a017; }
.tv-choice[data-letter="S"] { border-left: 4px solid #3d8b6e; }
.tv-choice[data-letter="C"] { border-left: 4px solid #3a6ea5; }

.tv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.tv-btn,
.tv-btn-ghost {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.15rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.tv-btn {
  background: var(--tv-accent);
  color: #0d1a16;
}

.tv-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.tv-btn-ghost {
  background: transparent;
  color: var(--tv-muted);
  border: 1px solid var(--tv-border);
}

.tv-chat h3 {
  margin: 0 0 0.25rem;
  font-family: var(--tv-font-display);
  font-weight: 500;
}

.tv-chat-log {
  height: min(360px, 45vh);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin: 0.75rem 0;
  padding-right: 0.25rem;
}

.tv-bubble {
  max-width: 95%;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  font-size: 0.92rem;
  line-height: 1.4;
  animation: tv-in 0.25s ease;
}

@keyframes tv-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.tv-bubble.student {
  align-self: flex-end;
  background: rgba(111, 191, 154, 0.18);
}

.tv-bubble.tutor {
  align-self: flex-start;
  background: rgba(224, 179, 90, 0.12);
}

.tv-chat-form {
  display: flex;
  gap: 0.45rem;
}

.tv-traits,
.tv-constellation,
.tv-explain {
  display: grid;
  gap: 0.45rem;
  margin: 1rem 0;
}

.tv-chip {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0.75rem;
  border-radius: 10px;
  border: 1px solid var(--tv-border);
  background: rgba(8, 16, 14, 0.35);
}

.tv-error {
  color: #ffc9c0;
  background: rgba(224, 122, 106, 0.15);
  border: 1px solid rgba(224, 122, 106, 0.35);
  border-radius: 10px;
  padding: 0.65rem 0.85rem;
  margin-bottom: 1rem;
}

.tv-header-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.tv-nav {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.tv-nav a {
  color: var(--tv-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 2px solid transparent;
  padding-bottom: 0.15rem;
}

.tv-nav a[aria-current="page"],
.tv-nav a:hover {
  color: var(--tv-accent);
  border-bottom-color: var(--tv-accent);
}

a.tv-btn-ghost {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.tv-ambiance {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--tv-muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.tv-ocr {
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--tv-border);
}

.tv-ocr input[type="file"] {
  display: block;
  margin: 0.5rem 0;
  color: var(--tv-muted);
  font-size: 0.85rem;
}

.hidden { display: none !important; }
