@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;
  --kw: #db2777;
  --kw-assert: #9333ea;
  --pass: #15803d;
  --fail: #b91c1c;
  --muted: #64748b;
}

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

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  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: var(--accent-soft);
  border-bottom: 1px solid var(--border);
}

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

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

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

.layout {
  display: grid;
  grid-template-columns: 22rem 6px 1fr;
  height: calc(100vh - 3rem);
}

.divider {
  background: var(--border);
  cursor: col-resize;
}

.divider:hover,
.divider.dragging {
  background: var(--accent);
}

.sidebar {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0.5rem 1rem;
}

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

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

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

.sidebar-actions .icon-button {
  color: var(--muted);
  padding: 0.25rem;
  display: inline-flex;
  align-items: center;
}

.sidebar-actions .icon-button:hover {
  color: var(--fg);
}

.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;
  cursor: pointer;
}

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

.exercise.current {
  background: var(--panel);
  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;
}

.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem 1rem 0;
  border-bottom: 1px solid var(--border);
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font: inherit;
  background: none;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 0.3rem 0.3rem 0 0;
  padding: 0.4rem 0.9rem;
  color: var(--muted);
  cursor: pointer;
}

.tab-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 0.25rem;
  background: var(--panel);
  border: 1px solid var(--border);
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1;
}

.tab.active .tab-num {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.tab.passed .tab-num {
  background: var(--pass);
  border-color: var(--pass);
  color: #ffffff;
}

.tab.failed .tab-num {
  background: var(--fail);
  border-color: var(--fail);
  color: #ffffff;
}

.tab.active {
  color: var(--fg);
  border-color: var(--border);
  background: var(--bg);
  margin-bottom: -1px;
}

.tab:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

.tab-panel.active {
  display: block;
}

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

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

.tab-panel 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 #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 h2 {
  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;
}

.modal-secondary {
  background: var(--panel);
  color: var(--fg);
}

.modal-danger {
  background: var(--fail);
  border-color: var(--fail);
}

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;
}

#revert {
  background: var(--panel);
  color: var(--fg);
}

.icon-button {
  background: none;
  border: none;
  border-radius: 0;
  padding: 0.2rem 0.4rem;
  font-size: 1.2rem;
  line-height: 1;
  color: var(--fg);
}

.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;
}

.auth-link {
  color: var(--accent);
  text-decoration: none;
}

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

.auth-button {
  padding: 0.25rem 0.7rem;
  font-size: 0.85rem;
  background: var(--panel);
  color: var(--fg);
}

.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;
}

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

.linklike {
  padding: 0;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.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; }
}

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

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

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

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

.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; }
}
