:root {
  color-scheme: light;
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --border: #e2e8f0;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.15);
  --radius: 14px;
  --editor-height: 320px;
  --editor-line-height: 1.55;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #1d4ed8 0%, transparent 35%),
    radial-gradient(circle at 90% 0%, #0ea5e9 0%, transparent 30%),
    linear-gradient(135deg, var(--bg), #1e1b4b);
  padding: 24px;
}

.app-shell {
  max-width: 1100px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.hero {
  color: #f8fafc;
  padding: 4px 6px;
}

.hero h1 {
  margin: 0;
  font-size: 2rem;
}

.hero p {
  margin: 8px 0 0;
  color: #cbd5e1;
}

.card {
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.security-alert {
  padding: 14px 16px;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #9f1239;
  font-weight: 700;
}

.controls {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  padding: 16px;
}

.control-item {
  display: grid;
  gap: 8px;
}

label {
  font-size: 0.92rem;
  color: var(--muted);
}

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

select,
input,
textarea {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

textarea {
  width: 100%;
  resize: none;
  height: var(--editor-height);
  line-height: var(--editor-line-height);
}

.editor-with-lines {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  height: var(--editor-height);
  background: #fff;
}

.line-numbers {
  position: absolute;
  inset: 0 auto 0 0;
  margin: 0;
  width: 52px;
  height: 100%;
  padding: 10px 8px;
  background: #f8fafc;
  color: #94a3b8;
  text-align: right;
  line-height: var(--editor-line-height);
  user-select: none;
  overflow: auto;
  pointer-events: none;
  z-index: 2;
  scrollbar-width: none;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
}

.line-numbers::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.editor-with-lines textarea {
  position: absolute;
  inset: 0;
  border: none;
  border-radius: 0;
  height: 100%;
  padding: 10px 12px 10px 62px;
  overflow: auto;
  background: transparent;
  z-index: 1;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  tab-size: 2;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 14px;
}

.actions {
  align-content: end;
  grid-template-columns: 1fr 1fr;
}

.btn {
  border: none;
  border-radius: 10px;
  padding: 11px 12px;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.2s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  color: #fff;
  background: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.btn-ghost {
  color: var(--primary);
  background: #eff6ff;
}

.editor-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr 1fr;
}

.panel {
  padding: 14px;
}

.side-stack {
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 12px;
}

.execution-args-group {
  display: grid;
  gap: 8px;
}

.stdin-editor-with-lines {
  height: calc(var(--editor-height) - 74px);
}

.panel-title {
  margin-bottom: 10px;
  font-weight: 600;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.9rem;
}

.hidden-file-input {
  display: none;
}

.output-panel pre {
  margin: 0;
  background: #0b1220;
  color: #dbeafe;
  border-radius: 10px;
  padding: 14px;
  min-height: 180px;
  overflow-x: auto;
  white-space: pre-wrap;
}

.upload-panel input[type="file"] {
  width: 100%;
  border: 1px dashed #94a3b8;
  border-radius: 10px;
  padding: 10px;
}

.tip {
  margin: 10px 0 0;
  font-size: 0.9rem;
  color: var(--muted);
}

.tip-code-block {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.tip-code-block summary {
  cursor: pointer;
  padding: 10px 12px;
  color: #334155;
  font-weight: 600;
}

.tip-code-block pre {
  margin: 0;
  padding: 12px;
  border-top: 1px solid var(--border);
  overflow-x: auto;
  white-space: pre;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
  line-height: 1.5;
  color: #0f172a;
}

.reserve-panel {
  padding: 16px;
}

.reserve-panel h2 {
  margin-top: 0;
  font-size: 1.05rem;
}

.reserve-panel p {
  margin-bottom: 0;
  color: var(--muted);
}

.site-footer {
  text-align: center;
  color: #cbd5e1;
  font-size: 0.9rem;
  padding: 4px 0 10px;
}

.help-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  width: 54px;
  height: 54px;
  border: none;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 28px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(37, 99, 235, 0.42);
  z-index: 60;
}

.help-fab:hover {
  background: var(--primary-hover);
}

.help-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 80;
}

.help-modal[hidden] {
  display: none;
}

.help-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.6);
}

.help-modal-dialog {
  position: relative;
  width: min(920px, calc(100vw - 32px));
  height: min(760px, calc(100vh - 32px));
  border-radius: 14px;
  background: #fff;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  box-shadow: 0 20px 55px rgba(2, 6, 23, 0.4);
  border: 1px solid #dbeafe;
}

.help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.help-modal-header h2 {
  margin: 0;
  font-size: 1rem;
}

.help-modal-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f8fafc;
  color: #334155;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.help-modal-body {
  position: relative;
  min-height: 0;
}

.help-modal-status {
  margin: 0;
  padding: 12px 14px;
  color: #334155;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
}

.help-modal-markdown {
  height: 100%;
  overflow: auto;
  padding: 18px 20px;
  color: #0f172a;
  line-height: 1.75;
  background: #fff;
}

.help-modal-markdown h1,
.help-modal-markdown h2,
.help-modal-markdown h3,
.help-modal-markdown h4,
.help-modal-markdown h5,
.help-modal-markdown h6 {
  margin: 1.2em 0 0.45em;
  line-height: 1.35;
}

.help-modal-markdown h1 {
  font-size: 1.45rem;
}

.help-modal-markdown h2 {
  font-size: 1.25rem;
}

.help-modal-markdown p {
  margin: 0.7em 0;
}

.help-modal-markdown ul,
.help-modal-markdown ol {
  margin: 0.5em 0 0.9em;
  padding-left: 1.4em;
}

.help-modal-markdown code {
  background: #e2e8f0;
  padding: 1px 6px;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 0.9em;
}

.help-modal-markdown pre {
  margin: 0.8em 0;
  padding: 12px;
  background: #0b1220;
  color: #dbeafe;
  border-radius: 10px;
  overflow: auto;
}

.help-modal-markdown pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.help-modal-markdown blockquote {
  margin: 0.8em 0;
  padding: 0.35em 0.9em;
  border-left: 4px solid #93c5fd;
  background: #eff6ff;
  color: #1e3a8a;
}

.help-modal-markdown hr {
  border: none;
  border-top: 1px solid #cbd5e1;
  margin: 1.1em 0;
}

@media (max-width: 900px) {
  .controls,
  .editor-grid {
    grid-template-columns: 1fr;
  }

  textarea {
    height: 260px;
  }

  .editor-with-lines {
    height: 260px;
  }

  .stdin-editor-with-lines {
    height: calc(260px - 74px);
  }

  .help-fab {
    right: 16px;
    bottom: 16px;
  }

  .help-modal-dialog {
    width: calc(100vw - 20px);
    height: calc(100vh - 20px);
  }
}
