:root {
  --bg: #060917;
  --card: #0f172a;
  --border: #1f2a44;
  --accent: #38bdf8;
  --accent-strong: #0ea5e9;
  --text: #f8fafc;
  --muted: #94a3b8;
  --danger: #f87171;
  --success: #4ade80;
  --warning: #fbbf24;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, rgba(14, 165, 233, 0.18), transparent 55%),
    radial-gradient(circle at 10% 20%, rgba(52, 211, 153, 0.18), transparent 45%),
    var(--bg);
  color: var(--text);
  padding: 2rem;
}

main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero {
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin: 0.25rem 0;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.75rem;
  color: var(--accent);
  margin: 0 0 0.25rem;
}

.subtitle {
  color: var(--muted);
  max-width: 620px;
}

.hero-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.65rem;
}

.contact-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0.7rem 1.4rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: #021222;
  text-decoration: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 10px 25px rgba(14, 165, 233, 0.35);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.contact-btn:hover,
.contact-btn:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 12px 30px rgba(14, 165, 233, 0.4);
  outline: none;
}

.contact-details {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
}

.card {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.6);
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}

.account-form,
.account-summary {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: rgba(2, 6, 23, 0.6);
  border: 1px solid var(--border);
}

.account-form button,
.account-summary button {
  align-self: flex-start;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.field span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.account-email {
  font-weight: 600;
  color: var(--text);
  word-break: break-word;
}

.stage-one {
  max-height: 2000px;
  transition: max-height 0.35s ease, opacity 0.25s ease, margin 0.35s ease, padding 0.35s ease;
  overflow: hidden;
}

.stage-one.collapsed {
  max-height: 0;
  opacity: 0;
  margin: 0;
  padding-top: 0;
  padding-bottom: 0;
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
  box-shadow: none;
  pointer-events: none;
}

.stage-toggle {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 30;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.5rem 1rem;
  color: var(--text);
  font-size: 0.85rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(2, 6, 23, 0.55);
  transition: border 0.2s ease, color 0.2s ease;
}

.stage-toggle:hover,
.stage-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: none;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
}

.section-heading h2,
.section-heading h3 {
  margin: 0;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
}

.section-heading.compact {
  align-items: center;
}

.label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.input,
.output,
.code-editor {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid var(--border);
  background: rgba(2, 6, 23, 0.7);
  color: var(--text);
  padding: 1rem;
  font-size: 1rem;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

textarea:focus {
  outline: 2px solid var(--accent);
}

.actions,
.editor-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.75rem;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

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

#generate-btn,
#submit-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #021222;
  box-shadow: 0 10px 25px rgba(14, 165, 233, 0.35);
}

.ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.65rem 1.5rem;
}

.status {
  font-size: 0.85rem;
  color: var(--muted);
}

.progress {
  position: relative;
  width: 180px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.2);
  overflow: hidden;
}

.progress-bar {
  position: absolute;
  inset: 0;
  width: 45%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(56, 189, 248, 0.2), rgba(56, 189, 248, 0.8), rgba(14, 165, 233, 0.2));
  animation: progress-sweep 1.2s ease-in-out infinite;
}

@keyframes progress-sweep {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(260%);
  }
}

.output {
  min-height: 220px;
}

.workspace {
  --problem-panel-width: 50%;
  display: flex;
  gap: 0;
  align-items: stretch;
  width: 100%;
}

.problem-panel,
.editor-panel {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.problem-panel {
  flex: 0 0 var(--problem-panel-width);
  min-width: 260px;
}

.editor-panel {
  flex: 1 1 auto;
  min-width: 320px;
}

.panel-divider {
  flex: 0 0 10px;
  cursor: col-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.panel-divider::before {
  content: '';
  width: 2px;
  height: 60%;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.4);
  transition: background 0.2s ease;
}

.panel-divider:hover::before,
.panel-divider:focus-visible::before,
.panel-divider.dragging::before {
  background: var(--accent);
}

.problem-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.problem-description p {
  margin: 0.5rem 0;
  line-height: 1.6;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.7);
}

.mono {
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--muted);
}

#constraints {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
}

.examples,
.testcases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.example,
.testcase {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1rem;
  background: rgba(2, 6, 23, 0.6);
}

.example pre,
.testcase pre {
  background: rgba(15, 23, 42, 0.9);
  border-radius: 0.5rem;
  padding: 0.75rem;
  overflow-x: auto;
}

.badge {
  padding: 0.4rem 0.8rem;
  border-radius: 0.5rem;
  background: rgba(56, 189, 248, 0.15);
  color: var(--accent);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.9rem;
}

.difficulty {
  margin: 0.25rem 0 0;
  font-weight: 600;
}

.difficulty[data-level='Easy'] {
  color: var(--success);
}

.difficulty[data-level='Medium'] {
  color: var(--warning);
}

.difficulty[data-level='Hard'] {
  color: var(--danger);
}

.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.editor-header-actions {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
}

.editor-controls {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 150px;
}

.select {
  appearance: none;
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.9), rgba(2, 6, 23, 0.8));
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.7rem 2.75rem 0.7rem 1rem;
  font-weight: 600;
  font-size: 0.95rem;
  position: relative;
  box-shadow: 0 12px 30px rgba(2, 6, 23, 0.55);
  transition: border 0.15s ease, box-shadow 0.15s ease;
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='10' viewBox='0 0 14 10' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M2 2l5 5 5-5' stroke='%2338bdf8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  background-size: 0.75rem;
}

.select:focus {
  outline: none;
  border-color: rgba(56, 189, 248, 0.8);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.25);
}

.code-editor {
  min-height: 320px;
  resize: vertical;
}

.CodeMirror {
  height: auto;
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: rgba(2, 6, 23, 0.9);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.95rem;
}

.CodeMirror pre {
  padding-left: 1rem;
}

.CodeMirror-focused {
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.35);
}

.results-panel {
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1rem;
  background: rgba(15, 23, 42, 0.9);
  max-height: 420px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1rem;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-item {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.85rem;
  background: rgba(2, 6, 23, 0.7);
}

.history-item.clickable {
  cursor: pointer;
  transition: border 0.2s ease, transform 0.2s ease;
}

.history-item.clickable:hover,
.history-item.clickable:focus-visible {
  border-color: var(--accent);
  transform: translateY(-2px);
  outline: none;
}

.history-item h4 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.history-item p {
  margin: 0.25rem 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.history-meta {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: var(--muted);
}

.history-actions {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 0.5rem;
}

.history-action-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 999px;
}

.history-action-btn:hover,
.history-action-btn:focus-visible {
  border-color: var(--danger);
  color: var(--danger);
  outline: none;
}

.result-summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 600;
}

.result-summary.pass {
  color: var(--success);
}

.result-summary.fail {
  color: var(--danger);
}

.result-item {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.85rem;
}

.result-item header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.result-item pre {
  margin: 0.35rem 0;
  max-height: 120px;
  overflow: auto;
}

.result-item .stdout {
  font-size: 0.85rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  padding: 0.85rem 1.2rem;
  border-radius: 0.75rem;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border);
  box-shadow: 0 20px 60px rgba(2, 6, 23, 0.65);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.success {
  border-color: rgba(74, 222, 128, 0.4);
  color: var(--success);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
}

.hidden {
  display: none !important;
}

@media (max-width: 960px) {
  body {
    padding: 1rem;
  }
  .workspace {
    flex-direction: column;
  }
  .hero {
    text-align: left;
    flex-direction: column;
    align-items: flex-start;
  }
  .hero-actions {
    align-items: flex-start;
  }
  .editor-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .editor-header-actions {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }
  .editor-controls {
    width: 100%;
  }
  .select {
    width: 100%;
  }
  .problem-panel,
  .editor-panel {
    flex: 1 1 auto;
    width: 100%;
  }
}
