:root {
  --bg: #f3f3f1;
  --bg-strong: #ffffff;
  --panel: #ffffff;
  --panel-border: #d8d5cf;
  --panel-border-soft: #e7e3dc;
  --text: #181818;
  --muted: #68635b;
  --accent: #181818;
  --accent-deep: #181818;
  --surface: #fcfcfa;
  --surface-strong: #f7f5f1;
  --ok: #24594a;
  --ok-soft: rgba(36, 89, 74, 0.12);
  --error: #8e3d33;
  --error-soft: rgba(142, 61, 51, 0.12);
  --pending: rgba(92, 85, 74, 0.08);
  --cursor: #d8d2c8;
  --shadow: none;
  --font-sans: "Avenir Next", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-display: "Avenir Next", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", "Consolas", monospace;
  --editor-font-size: 15px;
  --editor-line-height: 26px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

.page-shell {
  width: min(1120px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 420px);
  gap: 32px;
  align-items: start;
  margin-bottom: 20px;
}

.hero-intro {
  display: grid;
  gap: 20px;
}

.hero-copy-block {
  display: grid;
  gap: 0;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--panel-border-soft);
}

.eyebrow,
.panel-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 3.6vw, 3.8rem);
  line-height: 1.12;
  /* max-width: 11ch; */
  text-wrap: balance;
}

.hero-copy {
  max-width: 58ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.8;
  text-wrap: pretty;
}

.principles {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.principle-card {
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--panel-border-soft);
  border-radius: 0;
  background: transparent;
}

.principle-label,
.principle-value,
.principle-copy {
  margin: 0;
}

.principle-label {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.principle-value {
  margin-top: 8px;
  font-size: 0.98rem;
  font-weight: 600;
}

.principle-copy {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
  text-wrap: pretty;
}

.fetch-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border-soft);
  border-radius: 16px;
  box-shadow: var(--shadow);
}

.fetch-panel {
  padding: 18px;
  position: sticky;
  top: 20px;
}

.panel-lead {
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
}

.panel-copy {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.65;
  text-wrap: pretty;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.88rem;
  font-weight: 600;
}

input,
button,
.typing-input {
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
}

input {
  padding: 14px 16px;
}

input:focus,
.typing-input:focus {
  outline: 2px solid rgba(24, 24, 24, 0.08);
  border-color: rgba(24, 24, 24, 0.32);
}

.fetch-actions {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

button {
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  background: var(--accent);
  color: #ffffff;
  font-weight: 600;
  transition: transform 160ms ease-out, background-color 160ms ease-out, border-color 160ms ease-out;
}

button:hover {
  transform: translateY(-1px);
}

.ghost-button {
  background: #ffffff;
  border-color: var(--panel-border);
  color: var(--text);
}

.status-text {
  min-height: 1.4em;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.file-picker {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--panel-border-soft);
}

.file-picker.is-hidden {
  display: none;
}

.file-picker-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
}

.file-list {
  display: grid;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  margin-top: 12px;
  padding-right: 4px;
}

.file-option {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  border: 1px solid var(--panel-border-soft);
  border-radius: 12px;
  background: #ffffff;
  color: var(--text);
  text-align: left;
  box-shadow: none;
}

.file-option:hover {
  border-color: rgba(24, 24, 24, 0.24);
  background: var(--surface);
}

.file-option-path {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.5;
}

.file-option-ext {
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
}

.session-status {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 10px 0 14px;
  margin: 0 0 16px;
  border-top: 1px solid var(--panel-border-soft);
  border-bottom: 1px solid var(--panel-border-soft);
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

.panel {
  min-height: 64vh;
  padding: 16px;
}

.panel-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 28ch);
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
  min-width: 0;
  min-height: 72px;
}

.meta,
.progress-strip {
  color: var(--muted);
  font-size: 0.92rem;
}

.indent-control {
  display: grid;
  gap: 6px;
  justify-items: end;
  color: var(--muted);
  font-size: 0.86rem;
}

.indent-control span {
  font-weight: 600;
}

.indent-control select {
  min-width: 112px;
  padding: 8px 12px;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
}

.meta {
  max-width: 28ch;
  text-align: right;
  text-wrap: pretty;
  overflow-wrap: anywhere;
  min-width: 0;
  line-height: 1.5;
  max-height: 3em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.source-view-shell {
  position: relative;
}

.source-view {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px 0;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--panel-border-soft);
  min-width: 0;
}

.source-caret {
  position: absolute;
  width: 2px;
  height: var(--editor-line-height);
  background: var(--accent-deep);
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  z-index: 2;
  display: none;
}

.input-shell {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  position: relative;
  border: 1px solid var(--panel-border-soft);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  transition: border-color 160ms ease-out, box-shadow 160ms ease-out;
}

.input-shell:focus-within {
  border-color: rgba(24, 24, 24, 0.24);
  box-shadow: 0 0 0 3px rgba(24, 24, 24, 0.05);
}

.input-line-numbers {
  padding: 20px 14px 20px 0;
  color: rgba(104, 99, 91, 0.82);
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  text-align: right;
  user-select: none;
  background: var(--surface-strong);
  border-right: 1px solid var(--panel-border-soft);
  overflow: hidden;
  font-variant-numeric: tabular-nums;
}

.input-line-number {
  height: var(--editor-line-height);
  line-height: var(--editor-line-height);
}

.input-line-number.is-active-line {
  color: var(--accent-deep);
  font-weight: 600;
  background: rgba(24, 24, 24, 0.05);
  box-shadow: inset 2px 0 0 rgba(24, 24, 24, 0.34);
}

.code-line.is-active-line .line-number {
  color: var(--accent-deep);
  font-weight: 600;
}

.code-line.is-active-line .line-content {
  box-shadow: inset 2px 0 0 rgba(24, 24, 24, 0.12);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 100%;
  padding: 24px;
  color: var(--muted);
  text-align: center;
  line-height: 1.8;
}

.code-line {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 0;
  align-items: start;
  min-height: var(--editor-line-height);
  min-width: 0;
}

.line-number {
  text-align: right;
  padding: 0 14px 0 0;
  user-select: none;
  color: rgba(104, 99, 91, 0.82);
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
}

.line-content,
.typing-input {
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  font-kerning: none;
  font-variant-ligatures: none;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  tab-size: 2;
}

.line-content {
  padding-left: 20px;
  padding-right: 18px;
  min-width: 0;
}

.typing-input {
  min-width: 0;
  height: 100%;
  overflow-x: auto;
  overflow-y: auto;
  background: var(--surface);
  color: var(--text);
  outline: none;
}

.typing-input-line {
  min-height: var(--editor-line-height);
}

.typing-input::selection,
.typing-input *::selection {
  background: rgba(24, 24, 24, 0.14);
}

.typing-input .monaco-editor,
.typing-input .monaco-editor .margin,
.typing-input .monaco-editor .monaco-editor-background,
.typing-input .monaco-editor .inputarea.ime-input {
  background: var(--surface) !important;
}

.typing-input .monaco-editor {
  color: var(--text);
}

.typing-input .monaco-editor .view-lines {
  font-family: var(--font-mono) !important;
  font-size: var(--editor-font-size) !important;
  line-height: var(--editor-line-height) !important;
}

.char {
  border-radius: 4px;
}

.char.is-correct {
  background: var(--ok-soft);
  color: var(--ok);
}

.char.is-incorrect {
  background: var(--error-soft);
  color: var(--error);
}

.char.is-pending {
  background: transparent;
}

.char.is-current {
  background: rgba(216, 210, 200, 0.65);
  box-shadow: inset 0 -1px 0 rgba(24, 24, 24, 0.14);
}

.token-comment {
  color: #8a847a;
}

.token-keyword {
  color: #6d4037;
  font-weight: 600;
}

.token-string {
  color: #3d645a;
}

.token-number {
  color: #6d5d48;
}

.token-operator {
  color: #5f5a52;
}

.token-tag {
  color: #494949;
}

.token-attr {
  color: #5b5b5b;
}

.token-plain {
  color: inherit;
}

.source-view::-webkit-scrollbar,
.file-list::-webkit-scrollbar,
.typing-input::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.source-view::-webkit-scrollbar-thumb,
.file-list::-webkit-scrollbar-thumb,
.typing-input::-webkit-scrollbar-thumb {
  background: #d5d0c8;
  border-radius: 999px;
}

.source-view::-webkit-scrollbar-track,
.file-list::-webkit-scrollbar-track,
.typing-input::-webkit-scrollbar-track {
  background: transparent;
}


.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 960px) {

  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .principles {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .fetch-panel {
    position: static;
  }

  .page-shell {
    width: min(1120px, calc(100% - 24px));
    padding-top: 20px;
  }

  .fetch-actions {
    flex-direction: column;
  }

  .meta {
    max-width: none;
    text-align: left;
  }

  .indent-control {
    justify-items: start;
  }

  .source-view,
  .panel {
    min-height: auto;
  }

  .source-view,
  .input-shell,
  .typing-input {
    height: auto;
  }
}
