@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/Poppins-400-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/Poppins-400.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/Poppins-600-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
  font-family: 'Poppins';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('/assets/fonts/Poppins-600.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

@font-face {
  font-family: 'MesloLGS NF';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('/assets/fonts/MesloLGS-NF-Regular.ttf') format('truetype');
}

@font-face {
  font-family: 'MesloLGS NF';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('/assets/fonts/MesloLGS-NF-Bold.ttf') format('truetype');
}

:root {
  color-scheme: light;
  --bg: #f7f9fc;
  --fg: #1e293b;
  --panel: #e9eef7;
  --border: #cdd8ea;
  --accent: #2563eb;
  --accent-soft: #e6eefc;
  --accent-soft-purple: #e0e7ff;
  --accent-purple: #7c3aed;
  --kw: #db2777;
  --kw-assert: #9333ea;
  --pass: #16a34a;
  --fail: #b91c1c;
  --muted: #64748b;
}

body.dark {
  color-scheme: dark;
  --bg: #10151f;
  --fg: #e2e8f0;
  --panel: #1b2233;
  --border: #2e3a4f;
  --accent: #60a5fa;
  --accent-soft: #1a2540;
  --accent-soft-purple: #241d3f;
  --accent-purple: #a78bfa;
  --kw: #f472b6;
  --kw-assert: #c084fc;
  --pass: #22c55e;
  --fail: #f87171;
  --muted: #94a3b8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Poppins', system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
}

pre,
code,
.cm-editor,
.cm-content,
.cm-gutters {
  font-family: 'MesloLGS NF', ui-monospace, monospace;
}

.cm-behave-block,
.cm-behave-block * {
  color: var(--accent) !important;
  font-weight: 700;
}

.cm-behave-assert,
.cm-behave-assert * {
  color: var(--kw-assert) !important;
  font-weight: 700;
}

.cm-raku-keyword,
.cm-raku-keyword * {
  color: var(--kw) !important;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: radial-gradient(circle at 22rem 50%, var(--accent-soft-purple), var(--accent-soft));
  border-bottom: 1px solid var(--border);
}

.topbar h1 {
  font-size: 1.1rem;
  margin: 0;
  color: var(--accent);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
}

.topbar-link {
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
}

.topbar-link:hover {
  text-decoration: underline;
}

.topbar-link.active,
.auth-user.active {
  color: var(--kw);
}

.about-panel,
.profile-panel,
.rakuists-panel,
.playground-panel {
  display: none;
  overflow-y: auto;
  padding: 1.5rem 2rem 2rem;
  line-height: 1.65;
}

.about-panel h3,
.profile-panel h3,
.rakuists-panel h3,
.playground-panel h3 {
  margin: 0 0 1rem;
}

.about-panel code {
  background: var(--accent-soft);
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
}

/* An overlay view (About / Profile / Top Rakuists) replaces the exercise UI in
   the main panel. */
.main[data-view] .nav-tabs,
.main[data-view] .tab-content,
.main[data-view] .actions {
  display: none;
}

.main[data-view="about"] .about-panel,
.main[data-view="profile"] .profile-panel,
.main[data-view="rakuists"] .rakuists-panel,
.main[data-view="playground"] .playground-panel {
  display: block;
}

.playground-editor {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.playground-actions {
  margin: 0.85rem 0;
}

.playground-output pre {
  margin: 0;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: var(--panel);
  white-space: pre-wrap;
  overflow-x: auto;
  font-size: 0.9rem;
}

.playground-output .play-err {
  color: var(--fail);
  margin-top: 0.5rem;
}

.playground-output .play-exit {
  color: var(--muted);
  margin-top: 0.5rem;
}

.playground-output .result-timeout {
  margin-top: 0.75rem;
}

.profile-card {
  max-width: 28rem;
  margin: 0 0 1.25rem;
  padding: 1.25rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.profile-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.profile-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-weight: 600;
}

.profile-field input {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-weight: 400;
}

.profile-checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.field-hint {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85em;
}

.profile-actions {
  margin-top: 0.25rem;
}

.rakuists-table {
  width: auto;
  max-width: 34rem;
  /* Bootstrap table tokens pointed at the app palette: blue stripes, purple
     hover, themed borders and text. */
  --bs-table-color: var(--fg);
  --bs-table-bg: transparent;
  --bs-table-border-color: var(--border);
  --bs-table-striped-color: var(--fg);
  --bs-table-striped-bg: var(--accent-soft);
  --bs-table-hover-color: var(--fg);
  --bs-table-hover-bg: var(--accent-soft-purple);
}

.rakuists-table thead {
  background: linear-gradient(to right, var(--accent), var(--accent-purple));
}

.rakuists-table thead th {
  background: transparent;
  color: var(--bg);
}

.rakuists-table th,
.rakuists-table td {
  padding: 0.35rem 1rem;
  font-size: 0.85rem;
  text-align: center;
}

.rakuists-empty {
  color: var(--muted);
}

.brand .logo {
  width: 34px;
  height: 34px;
  flex: none;
  color: var(--fg);
}

.brand h1 .tld {
  color: #a78bfa;
}

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 22rem 1fr;
}

.sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0.5rem 1rem;
  background: linear-gradient(to bottom left, var(--accent-soft-purple), var(--accent-soft));
}

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

.sidebar-header h4 {
  margin: 0.2rem 0;
}

.sidebar-actions {
  display: flex;
  gap: 0.1rem;
}

.sidebar-actions .btn {
  padding: 0.3rem 0.3rem;
  font-size: 0.75rem;
  line-height: 1;
}

.sidebar-actions svg {
  width: 1.05rem;
  height: 1.05rem;
  display: block;
}

.exercises {
  list-style: none;
  margin: 0;
  padding: 0;
}

.group {
  list-style: none;
}

.group-header {
  width: 100%;
  text-align: left;
  font: inherit;
  font-weight: 600;
  background: none;
  border: none;
  border-radius: 0.25rem;
  padding: 0.35rem 0.4rem;
  color: var(--accent);
  cursor: pointer;
}

.group-header:hover {
  background: var(--panel);
}

.group-header::before {
  content: "▾";
  display: inline-block;
  width: 1rem;
  color: var(--muted);
}

.group.collapsed .group-header::before {
  content: "▸";
}

.group-items {
  list-style: none;
  margin: 0 0 0.25rem;
  padding: 0 0 0 0.5rem;
}

.group.collapsed .group-items {
  display: none;
}

.exercise {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.exercise:hover {
  background: var(--panel);
}

.exercise.current {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg));
  box-shadow: inset 3px 0 0 var(--accent);
  padding-left: 0.7rem;
  font-weight: 600;
}

.exercise .marker {
  width: 0.95rem;
  height: 0.95rem;
  flex-shrink: 0;
  border-radius: 0.2rem;
  border: 1px solid var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  line-height: 1;
}

.exercise.done .marker {
  background: var(--pass);
  border-color: var(--pass);
  color: #ffffff;
}

.exercise.done .marker::after {
  content: "\2713";
}

.main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: linear-gradient(to bottom right, var(--accent-soft-purple), var(--accent-soft));
}

#main-tabs {
  padding: 0.5rem 1rem 0;
  /* Bootstrap nav-tabs in the app palette. The active tab gets a solid accent
     fill with inverted (background-colored) text for high contrast against the
     gradient panel. */
  --bs-nav-link-color: var(--muted);
  --bs-nav-link-hover-color: var(--fg);
  --bs-nav-tabs-border-color: var(--border);
  --bs-nav-tabs-link-hover-border-color: var(--border);
  --bs-nav-tabs-link-active-color: var(--accent);
  --bs-nav-tabs-link-active-bg: var(--bg);
  --bs-nav-tabs-link-active-border-color: var(--border) var(--border) var(--bg);
}

#main-tabs .nav-link {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

#tab-results.passed {
  color: var(--pass);
}

#tab-results.failed {
  color: var(--fail);
}

.tab-content {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg);
}

.tab-pane {
  padding: 1rem;
}

.tab-pane h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin: 0 0 0.4rem;
}

.tab-pane h3:not(:first-child) {
  margin-top: 1rem;
}

.tab-pane pre {
  margin: 0;
  padding: 0.75rem;
  background: var(--panel);
  border: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre-wrap;
}

.readme h2 {
  font-size: 1.2rem;
  margin: 0 0 0.6rem;
}

.readme h3 {
  font-size: 1rem;
  margin: 1rem 0 0.4rem;
}

.readme p {
  margin: 0 0 0.85rem;
  line-height: 1.55;
}

.readme code {
  font-family: 'MesloLGS NF', ui-monospace, monospace;
  background: var(--panel);
  padding: 0.05rem 0.3rem;
  border-radius: 0.25rem;
  font-size: 0.92em;
}

.readme a {
  color: var(--accent);
}

.readme .md-code {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.75rem;
  overflow-x: auto;
  white-space: pre;
}

.docs-link {
  display: inline-block;
  margin-top: 0.4rem;
  color: var(--accent);
  text-decoration: none;
  font-size: 0.9rem;
}

.docs-link:hover {
  text-decoration: underline;
}

#editor,
#spec {
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  overflow: hidden;
}

.actions {
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-top: 1px solid var(--border);
}

.actions[hidden] {
  display: none;
}

.actions #solution {
  margin-left: auto;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
}

.modal[hidden] {
  display: none;
}

.modal-box {
  width: min(26rem, calc(100vw - 2rem));
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 0.6rem;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  padding: 1.25rem 1.4rem;
}

.modal-box-wide {
  width: min(42rem, calc(100vw - 2rem));
}

.solution-code {
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  overflow: hidden;
  margin: 0 0 1.1rem;
}

.solution-code .cm-editor {
  max-height: 60vh;
}

.solution-code .cm-scroller {
  overflow: auto;
}

.modal-box h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
}

.modal-box p {
  margin: 0 0 1.1rem;
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

button {
  font: inherit;
  padding: 0.35rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
}

button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.auth {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
}

.auth-user {
  font-weight: 600;
  color: var(--accent);
  background: none;
  border: none;
  padding: 0;
  margin-right: 0.5rem;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
}

.auth-user:hover {
  text-decoration: underline;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}

.login-field input {
  font: inherit;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  background: var(--panel);
  color: var(--fg);
}

.login-error {
  color: var(--fail);
  font-size: 0.85rem;
  margin: 0;
}

.login-notice {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0;
}

.modal-box .auth-switch {
  margin: 0.9rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: right;
}

.modal-box .auth-switch-spaced {
  margin-top: 1.6rem;
}

.modal-box .auth-switch-forgot {
  margin-top: 1.4rem;
}

.spec-group {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0.8rem 0 0.3rem;
}

.spec-group:first-child {
  margin-top: 0;
}

.examples {
  list-style: none;
  margin: 0;
  padding: 0;
}

.example {
  padding: 0.3rem 0.5rem;
  border-left: 3px solid var(--border);
}

.example.pass {
  border-left-color: var(--pass);
}

.example.fail {
  border-left-color: var(--fail);
}

.example.running {
  border-left-color: var(--accent);
  animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.spin {
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

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

.example .detail {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-line;
}

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

.result-fail,
.result-error,
.result-timeout {
  color: var(--fail);
}

.load-error {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  white-space: pre-wrap;
  overflow-x: auto;
}

.result-running {
  color: var(--muted);
}

.run-countdown {
  margin-top: 0.35rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.9rem;
}

.result-running .dots span {
  animation: dot-blink 1.4s infinite both;
}

.result-running .dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.result-running .dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes dot-blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}
