:root {
  --bg: #121214;
  --bg-input: #2b2b2f;
  --border-input: #3a3a3f;
  --text-main: #e0e0e0;
  --text-muted: #88888e;
  --accent-blue: #2463eb;
  --accent-cyan: #22d3ee;
  --accent-violet: #8b5cf6;
  --accent-rose: #fb7185;
  --accent-gold: #fbbf24;
  --accent-glow: rgba(36, 99, 235, 0.15);
  --radius-dialog: 32px;
  --radius-button: 12px;
  --max-width: 860px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  background-color: var(--bg);
  color: var(--text-main);
  overflow-x: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.stage-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px;
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.stage-shell::before,
.stage-shell::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease;
  z-index: -1;
}

.stage-shell::before {
  background:
    linear-gradient(115deg, transparent 0%, rgba(34, 211, 238, 0.05) 42%, rgba(139, 92, 246, 0.08) 50%, transparent 58%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.028) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.022) 0 1px, transparent 1px 72px);
  background-size: 220% 220%, 72px 72px, 72px 72px;
  animation: thoughtSurface 18s linear infinite;
}

.stage-shell::after {
  background:
    linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.045) 50%, transparent 100%),
    linear-gradient(90deg, transparent, rgba(34, 211, 238, 0.05), transparent);
  transform: translateY(-120%);
  animation: scanField 7.2s ease-in-out infinite;
}

.stage-shell.is-thinking::before {
  opacity: 1;
}

.stage-shell.is-thinking::after {
  opacity: 0.9;
}

/* Brand */
.brand-header {
  padding: 20px 0;
  display: flex;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: var(--text-main);
  opacity: 0.9;
}

/* Main Content Area */
.main-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  max-width: var(--max-width);
  margin: 0 auto;
  width: 100%;
}

.hero-section {
  text-align: center;
  margin-bottom: 40px;
}

.hero-section h1 {
  font-size: 32px;
  font-weight: 700;
  margin-bottom: 24px;
  letter-spacing: 0;
}

/* Segmented Control (Presets) */
.segmented-control {
  display: inline-flex;
  background: #1e1e21;
  padding: 4px;
  border-radius: 999px;
  margin-bottom: 40px;
  border: 1px solid #2a2a2d;
}

.segment-btn {
  padding: 8px 20px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.segment-btn.active {
  background: #2b2b2f;
  color: #fff;
  box-shadow: 0 0 0 1px var(--accent-blue);
}

/* Dialogue Box */
.dialogue-box {
  background: var(--bg-input);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-dialog);
  width: 100%;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.dialogue-box:focus-within {
  border-color: #4a4a4f;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
}

.dialogue-box textarea {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 16px;
  resize: none;
  width: 100%;
  min-height: 80px;
  outline: none;
  margin-bottom: 12px;
  font-family: inherit;
}

.dialogue-box textarea::placeholder {
  color: #666;
}

.dialogue-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.footer-left {
  display: flex;
  gap: 12px;
  align-items: center;
}

.upload-trigger, .sample-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #3a3a3f;
  background: transparent;
  color: #999;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-trigger:hover, .sample-trigger:hover {
  background: #35353a;
  color: #fff;
}

.upload-trigger.filled {
  color: #4ade80;
  border-color: rgba(74, 222, 128, 0.3);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s, opacity 0.2s;
}

.send-btn:hover {
  transform: scale(1.05);
}

.send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

.send-btn svg {
  width: 20px;
  height: 20px;
}

/* Running State */
.running-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  width: 100%;
  min-height: 380px;
  justify-content: center;
  animation: thinkingEnter 0.8s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.thinking-core {
  width: 210px;
  height: 210px;
  position: relative;
  display: grid;
  place-items: center;
  margin-bottom: 30px;
}

.signal-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  opacity: 0.82;
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 59%, #000 64%, transparent 65%);
  mask: radial-gradient(circle, transparent 58%, #000 59%, #000 64%, transparent 65%);
}

.ring-one {
  background: conic-gradient(from 0deg, transparent 0 18%, rgba(34, 211, 238, 0.96), transparent 42% 100%);
  animation: ringSpin 7.5s linear infinite;
}

.ring-two {
  inset: 22px;
  background: conic-gradient(from 120deg, transparent 0 20%, rgba(139, 92, 246, 0.92), transparent 48% 100%);
  animation: ringSpinReverse 10s linear infinite;
}

.ring-three {
  inset: 44px;
  background: conic-gradient(from 240deg, transparent 0 22%, rgba(251, 113, 133, 0.76), transparent 54% 100%);
  animation: ringSpin 13s linear infinite;
}

.particle-field {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: fieldBreathe 5.8s ease-in-out infinite;
}

.particle-field span {
  --angle: calc(var(--i) * 13deg);
  --distance: calc(42px + var(--i) * 1.45px);
  position: absolute;
  left: 50%;
  top: 50%;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent-cyan) 66%, white);
  box-shadow: 0 0 12px rgba(34, 211, 238, 0.75);
  transform: rotate(var(--angle)) translateX(var(--distance));
  transform-origin: 0 0;
  opacity: 0.28;
  animation: particlePulse 4.8s ease-in-out infinite;
  animation-delay: calc(var(--i) * -0.17s);
}

.particle-field span:nth-child(3n) {
  background: color-mix(in srgb, var(--accent-violet) 74%, white);
  box-shadow: 0 0 12px rgba(139, 92, 246, 0.65);
}

.particle-field span:nth-child(5n) {
  background: color-mix(in srgb, var(--accent-gold) 72%, white);
  box-shadow: 0 0 10px rgba(251, 191, 36, 0.52);
}

.core-mark {
  width: 86px;
  height: 86px;
  border-radius: 24px;
  position: relative;
  display: grid;
  place-items: center;
  color: #fff;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04)),
    linear-gradient(135deg, rgba(36, 99, 235, 0.42), rgba(139, 92, 246, 0.25));
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow:
    0 18px 70px rgba(36, 99, 235, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.26);
  overflow: hidden;
  animation: coreFloat 4.8s ease-in-out infinite;
}

.core-mark::before {
  content: "";
  position: absolute;
  inset: -55%;
  background: conic-gradient(from 90deg, transparent, rgba(34, 211, 238, 0.35), transparent, rgba(251, 113, 133, 0.22), transparent);
  animation: coreSweep 8s linear infinite;
}

.core-mark::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 23px;
  background: rgba(18, 18, 20, 0.72);
  backdrop-filter: blur(18px);
}

.core-mark span {
  position: relative;
  z-index: 1;
  font-size: 34px;
  font-weight: 700;
  text-shadow: 0 0 24px rgba(34, 211, 238, 0.42);
}

.status-text {
  width: min(100%, 760px);
  min-height: 32px;
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 18px;
  background: linear-gradient(90deg, #f8fafc, var(--accent-cyan), var(--accent-violet), #f8fafc);
  background-size: 260% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: textFlow 8s ease-in-out infinite;
}

.timer-text {
  color: rgba(224, 224, 224, 0.58);
  font-size: 14px;
  margin-top: 14px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
}

.glow-loader {
  width: min(360px, 76vw);
  height: 8px;
  background: rgba(255, 255, 255, 0.055);
  position: relative;
  overflow: hidden;
  border-radius: 999px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.05),
    0 12px 38px rgba(36, 99, 235, 0.12);
}

.glow-loader::before {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: inherit;
  background-image: repeating-linear-gradient(90deg, transparent 0 14px, rgba(255, 255, 255, 0.12) 14px 15px);
  opacity: 0.36;
}

.glow-loader::after {
  content: "";
  position: absolute;
  width: 46%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), var(--accent-violet), var(--accent-rose), transparent);
  box-shadow:
    0 0 18px rgba(34, 211, 238, 0.55),
    0 0 34px rgba(139, 92, 246, 0.32);
  animation: loading 3.8s infinite cubic-bezier(0.45, 0, 0.2, 1);
}

@keyframes loading {
  0% { left: -46%; }
  45% { left: 38%; }
  100% { left: 100%; }
}

@keyframes thoughtSurface {
  0% { background-position: 180% 50%, 0 0, 0 0; }
  100% { background-position: -40% 50%, 72px 0, 0 72px; }
}

@keyframes scanField {
  0%, 18% { transform: translateY(-120%); }
  52% { transform: translateY(120%); }
  100% { transform: translateY(120%); }
}

@keyframes thinkingEnter {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes ringSpin {
  to { transform: rotate(360deg); }
}

@keyframes ringSpinReverse {
  to { transform: rotate(-360deg); }
}

@keyframes fieldBreathe {
  0%, 100% { transform: scale(0.96); opacity: 0.66; }
  50% { transform: scale(1.05); opacity: 1; }
}

@keyframes particlePulse {
  0%, 100% { opacity: 0.16; scale: 0.72; }
  45% { opacity: 0.86; scale: 1.25; }
  68% { opacity: 0.34; scale: 0.9; }
}

@keyframes coreFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@keyframes coreSweep {
  to { transform: rotate(360deg); }
}

@keyframes textFlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* Result State */
.result-view {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 22px;
  animation: fadeIn 0.5s ease;
}

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

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 6px;
}

.result-header h2 {
  font-size: 24px;
  margin-bottom: 8px;
}

.result-header p {
  color: var(--text-muted);
  font-size: 14px;
}

.result-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 0;
}

.result-pills span,
.course-badge,
.campus-meta span {
  color: rgba(224, 224, 224, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
  padding: 7px 10px;
}

.result-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.section-header {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.section-header h3 {
  font-size: 17px;
  font-weight: 650;
}

.section-kicker {
  display: block;
  color: var(--accent-cyan);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  margin-bottom: 3px;
}

.course-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.course-item {
  background: #1e1e21;
  border: 1px solid #2a2a2d;
  border-radius: 16px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-decoration: none;
  color: inherit;
  transition: all 0.2s;
}

.course-item:hover {
  background: #252528;
  border-color: #3a3a3f;
  transform: translateX(4px);
}

.course-info {
  flex: 1;
  min-width: 0;
  margin-right: 12px;
}

.course-info h3,
.course-info h4 {
  font-size: 16px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.course-info p {
  font-size: 13px;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.course-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.course-title-row h4 {
  flex: 1;
  min-width: 0;
}

.course-badge {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

.campus-item {
  align-items: flex-start;
}

.campus-item:hover {
  transform: none;
}

.campus-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.inline-link {
  display: inline-flex;
  color: var(--accent-cyan);
  font-size: 13px;
  text-decoration: none;
  margin-top: 10px;
}

.inline-link:hover {
  color: #fff;
}

.external-icon {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 18px;
}

.export-btn {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid rgba(34, 211, 238, 0.28);
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.08);
  color: #dff8ff;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.export-btn:hover {
  background: rgba(34, 211, 238, 0.14);
  border-color: rgba(34, 211, 238, 0.42);
  transform: translateY(-1px);
}

.empty-result {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 18px 20px;
  font-size: 14px;
}

.path-details {
  margin-top: 10px;
  background: #1e1e21;
  border-radius: 16px;
  overflow: hidden;
}

.path-details summary {
  padding: 16px 20px;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  user-select: none;
}

.path-details pre {
  padding: 0 20px 20px;
  font-size: 13px;
  color: #ccc;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
}

.reset-btn {
  background: transparent;
  border: 1px solid #3a3a3f;
  color: var(--text-muted);
  padding: 10px 24px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 14px;
  align-self: center;
}

.reset-btn:hover {
  background: #1e1e21;
  color: #fff;
}

.result-actions {
  display: flex;
  justify-content: center;
  padding-top: 8px;
}

.error-msg {
  color: #ef4444;
  font-size: 13px;
  margin-top: 12px;
  text-align: center;
}

/* Utilities */
[v-cloak] { display: none; }

@media (max-width: 768px) {
  .hero-section h1 {
    font-size: 24px;
  }
  .dialogue-box {
    border-radius: 24px;
    padding: 12px 16px;
  }
  .dialogue-footer {
    flex-wrap: wrap;
    gap: 12px;
  }
  .footer-left {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }
  .segmented-control {
    width: 100%;
    justify-content: center;
  }
  .segment-btn {
    padding: 6px 12px;
    font-size: 13px;
  }
  .running-view {
    min-height: 340px;
  }
  .thinking-core {
    width: 172px;
    height: 172px;
    margin-bottom: 24px;
  }
  .ring-two {
    inset: 18px;
  }
  .ring-three {
    inset: 36px;
  }
  .core-mark {
    width: 72px;
    height: 72px;
    border-radius: 20px;
  }
  .core-mark::after {
    border-radius: 19px;
  }
  .core-mark span {
    font-size: 29px;
  }
  .status-text {
    font-size: 18px;
    min-height: 56px;
    padding: 0 8px;
  }
  .particle-field span {
    --distance: calc(34px + var(--i) * 1.1px);
  }
  .result-header,
  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .result-pills {
    justify-content: flex-start;
  }
  .course-item {
    border-radius: 14px;
    padding: 14px 16px;
  }
  .course-title-row {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }
  .course-badge {
    max-width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
