:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef2f6;
  --text: #17202a;
  --muted: #687385;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --danger: #b42318;
  --code: #101827;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Nirmala UI", system-ui, sans-serif;
}

button,
select,
textarea,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
  margin: 18px 0 10px;
}

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

button,
select {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  min-height: 36px;
  border-radius: 6px;
  padding: 7px 11px;
  cursor: pointer;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 10px;
}

input:focus,
textarea:focus,
button:focus-visible,
select:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid #14b8a6;
  outline-offset: 2px;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 7px 11px;
  text-decoration: none;
}

button:hover,
select:hover,
.nav-link:hover {
  border-color: #b8c5d4;
}

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

button.primary:hover {
  background: var(--accent-strong);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 1.1fr) minmax(320px, 0.9fr);
  gap: 14px;
  padding: 14px;
  min-height: 0;
}

.editor-panel,
.result-panel {
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.editor-panel {
  display: grid;
  grid-template-rows: auto minmax(360px, 1fr) auto;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--line);
  font-weight: 650;
}

.editor-wrap {
  position: relative;
  min-height: 520px;
  background: var(--code);
  overflow: hidden;
}

#source,
.highlight-layer {
  width: 100%;
  height: 100%;
  min-height: 520px;
  border: 0;
  outline: none;
  margin: 0;
  padding: 16px;
  line-height: 1.55;
  font-family: Consolas, "Nirmala UI", monospace;
  font-size: 15px;
  font-weight: 400;
  font-kerning: none;
  font-variant-ligatures: none;
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
}

#source {
  position: absolute;
  inset: 0;
  resize: none;
  color: transparent;
  background: transparent;
  caret-color: #ffffff;
  overflow: auto;
  z-index: 2;
}

#source::selection {
  background: rgba(82, 123, 255, 0.42);
}

.highlight-layer {
  position: absolute;
  inset: 0;
  color: #e7eef8;
  background: var(--code);
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.tok-keyword {
  color: #7dd3fc;
  font-weight: 400;
}

.tok-function {
  color: #c4b5fd;
  font-weight: 400;
}

.tok-value {
  color: #fca5a5;
}

.tok-number {
  color: #fde68a;
}

.tok-operator {
  color: #86efac;
  font-weight: 400;
}

.tok-comment {
  color: #9ca3af;
  font-style: normal;
}

.keyboard-panel {
  border-top: 1px solid var(--line);
  padding: 12px;
  background: #fbfcfe;
}

.keyboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.keyboard-head h2 {
  margin: 0;
}

.physical-keyboard {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.key-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(38px, 1fr);
  gap: 5px;
  min-width: 700px;
}

.key {
  min-height: 36px;
  padding: 5px 6px;
  border-radius: 6px;
  font-family: Consolas, "Nirmala UI", monospace;
  white-space: nowrap;
}

.key.wide {
  grid-column: span 2;
}

.key.wider {
  grid-column: span 3;
}

.key.widest {
  grid-column: span 4;
}

.key.space {
  grid-column: span 10;
}

.key.active {
  border-color: #0f766e;
  background: #ccfbf1;
  color: #134e4a;
}

.muted-key {
  color: var(--muted);
}

.keyboard-group,
.mapping-guide,
.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.keyboard-group {
  margin-top: 8px;
}

.keyboard-group > span {
  min-width: 74px;
  color: var(--muted);
  font-size: 13px;
}

.keyboard-group button {
  min-width: 34px;
  min-height: 32px;
  padding: 5px 8px;
}

.mapping-guide {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
}

.mapping-guide span,
.legend span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 6px;
  padding: 4px 8px;
  background: #f0f4f8;
  color: var(--text);
  font-size: 13px;
}

.mark {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 6px;
}

.mark.keyword {
  background: #0284c7;
}

.mark.function {
  background: #8b5cf6;
}

.mark.value {
  background: #ef4444;
}

.mark.number {
  background: #d97706;
}

.mark.operator {
  background: #16a34a;
}

.mark.comment {
  background: #6b7280;
}

.tabs {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.tab {
  background: transparent;
  border-color: transparent;
}

.tab.active {
  background: var(--surface);
  border-color: var(--line);
}

.pane {
  display: none;
  padding: 14px;
  height: calc(100vh - 126px);
  overflow: auto;
}

.pane.active {
  display: block;
}

label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 13px;
}

#stdin {
  width: 100%;
  min-height: 82px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 14px;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 220px;
  padding: 14px;
  border-radius: 6px;
  background: #111827;
  color: #e7eef8;
  font-family: Consolas, "Nirmala UI", monospace;
  line-height: 1.5;
}

pre.error {
  color: #ffd7d3;
  border: 1px solid var(--danger);
}

.help table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
}

.help th,
.help td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}

.learn-shell {
  max-width: 1040px;
  margin: 0 auto;
  padding: 20px;
}

.learn-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.learn-section {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  margin-bottom: 14px;
}

.learn-section p,
.learn-section li {
  line-height: 1.7;
}

.learn-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.learn-section table {
  width: 100%;
  border-collapse: collapse;
}

.learn-section th,
.learn-section td {
  border-bottom: 1px solid var(--line);
  padding: 9px 8px;
  text-align: left;
  vertical-align: top;
}

.learn-section th {
  color: var(--muted);
  font-size: 13px;
}

.small-note {
  color: var(--muted);
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 14px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  background: var(--surface);
  font-size: 14px;
}

.footer-stats {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.copyright {
  margin-left: auto;
  text-align: right;
}

.learn-shell .site-footer {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 2px 0 18px;
}

.site-footer strong {
  color: var(--text);
}

.context-menu {
  position: fixed;
  z-index: 1000;
  display: none;
  min-width: 180px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18);
}

.context-menu.open {
  display: grid;
  gap: 4px;
}

.context-menu button {
  width: 100%;
  min-height: 34px;
  justify-content: flex-start;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text);
  box-shadow: none;
}

.context-menu button:hover,
.context-menu button:focus-visible {
  background: #e8f5f3;
  outline: none;
}

.context-menu button:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.55;
}

.help th {
  color: var(--muted);
  font-size: 13px;
}

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chips span,
.chips a {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 8px;
  border-radius: 6px;
  background: #e8f5f3;
  color: #0b5f59;
  font-family: Consolas, "Nirmala UI", monospace;
  text-decoration: none;
}

.support-layout {
  display: grid;
  grid-template-columns: minmax(240px, 0.8fr) minmax(300px, 1.2fr);
  gap: 20px;
  align-items: start;
}

.support-form {
  display: grid;
  gap: 10px;
}

.support-form textarea {
  min-height: 180px;
  resize: vertical;
}

.support-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.support-actions span,
.feedback-status {
  color: var(--muted);
}

.feedback-open {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 950;
  min-height: 42px;
  border-color: #0f766e;
  background: #0f766e;
  color: #ffffff;
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.25);
}

.feedback-modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.5);
}

.feedback-modal.open {
  display: flex;
}

.feedback-box {
  position: relative;
  width: min(100%, 460px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 20px;
  box-shadow: 0 24px 56px rgba(15, 23, 42, 0.24);
}

.feedback-box h2 {
  margin-top: 0;
}

.feedback-close {
  position: absolute;
  top: 10px;
  right: 10px;
  min-width: 34px;
  width: 34px;
  padding: 0;
  font-size: 22px;
  line-height: 1;
}

.star-row {
  display: flex;
  gap: 6px;
  margin: 12px 0;
}

.star-row button {
  min-width: 40px;
  width: 40px;
  padding: 0;
  border-color: #f59e0b;
  color: #b45309;
  font-size: 24px;
}

.star-row button.active {
  background: #fef3c7;
}

.feedback-box textarea {
  min-height: 120px;
  resize: vertical;
}

.feedback-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

@media (max-width: 900px) {
  .topbar,
  .workspace {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .actions {
    justify-content: flex-start;
  }

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

  .learn-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .learn-grid {
    grid-template-columns: 1fr;
  }

  .support-layout {
    grid-template-columns: 1fr;
  }

  .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .footer-stats {
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
  }

  .copyright {
    margin-left: 0;
    text-align: left;
  }

  #source,
  .highlight-layer,
  .editor-wrap,
  .pane {
    min-height: 420px;
    height: auto;
  }

  .keyboard-head {
    align-items: flex-start;
    flex-direction: column;
  }
}
