: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: "JetBrains Mono", "Menlo", "Monaco", "Consolas", "Liberation Mono", monospace;
  --editor-font-size: 15px;
  --editor-line-height: 26px;
  --editor-min-height: 176px;
}

* {
  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: 18px;
}

.hero-copy-block {
  display: grid;
  gap: 0;
  padding-bottom: 20px;
}

.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.4rem, 4vw, 4.2rem);
  line-height: 1.05;
  text-wrap: balance;
}

.hero-copy {
  max-width: 60ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.75;
  text-wrap: pretty;
}

.hero-note {
  margin: 0;
  max-width: 40ch;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
  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: grid;
  gap: 12px;
  margin-top: 16px;
}

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

.primary-action {
  width: 100%;
}

.secondary-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
}

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

.subtle-button {
  padding-inline: 14px;
}

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

.editor-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 12px;
}

.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;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 1px), calc(100% - 12px) calc(50% - 1px);
  background-repeat: no-repeat;
  background-size: 6px 6px, 6px 6px;
  color: var(--text);
  font: inherit;
  padding-right: 34px;
}

select {
  appearance: none;
}

.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;
  min-height: var(--editor-min-height);
}

.source-view.is-empty {
  display: grid;
  place-items: center;
  padding: 24px;
}

.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;
  min-height: var(--editor-min-height);
}

.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;
  min-height: var(--editor-min-height);
}

.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%;
  width: min(38ch, 100%);
  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;
  font-variant-numeric: tabular-nums;
  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;
  min-height: var(--editor-min-height);
}

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

  .fetch-panel {
    position: static;
  }

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

  .fetch-actions {
    gap: 10px;
  }

  .secondary-actions {
    grid-template-columns: 1fr;
  }

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

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

  .editor-controls {
    justify-content: start;
  }

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

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