:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --text: #16211d;
  --muted: #66756f;
  --line: #dce4df;
  --accent: #087f6f;
  --accent-dark: #056154;
  --accent-soft: #dff3ef;
  --warning: #a85f00;
  --danger: #b3261e;
  --success: #146c43;
  --shadow: 0 18px 50px rgba(30, 52, 44, 0.12);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(8, 127, 111, 0.12), transparent 38%),
    linear-gradient(315deg, rgba(188, 82, 61, 0.10), transparent 34%),
    var(--bg);
  color: var(--text);
}

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

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.workspace {
  display: grid;
  gap: 16px;
}

.topbar,
.input-panel,
.settings-panel,
.results-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 5vw, 48px);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
  line-height: 1.25;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.status-pill {
  min-width: 112px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.status-pill.bad {
  background: #ffe7df;
  color: var(--danger);
}

.tool-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 16px;
}

.input-panel,
.settings-panel,
.results-panel {
  padding: 18px;
}

.panel-head,
.results-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

textarea {
  width: 100%;
  min-height: 300px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  outline: none;
  background: #fbfcfb;
  color: var(--text);
  line-height: 1.55;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(8, 127, 111, 0.14);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary-button {
  min-width: 148px;
  padding: 0 18px;
  background: var(--accent);
  color: white;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
}

.secondary-button {
  padding: 0 14px;
  background: #edf2ef;
  color: #23332e;
}

.secondary-button:hover:not(:disabled) {
  background: #e0e9e4;
}

.icon-button {
  width: 36px;
  min-height: 36px;
  background: #edf2ef;
  color: #31413b;
  font-size: 22px;
}

.button-icon {
  width: 18px;
  margin-right: 8px;
  transition: transform 0.2s ease;
}

.primary-button.loading .button-icon {
  animation: spin 0.8s linear infinite;
}

.settings-panel {
  display: grid;
  align-content: start;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: #31413b;
  font-size: 13px;
  font-weight: 700;
}

input,
select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 11px;
  outline: none;
  background: #fbfcfb;
  color: var(--text);
}

.results-panel {
  overflow: hidden;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 720px;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f6f8f7;
  color: #53625c;
  font-size: 13px;
}

tr:last-child td {
  border-bottom: 0;
}

.code-cell {
  font-size: 22px;
  font-weight: 800;
  color: var(--success);
  letter-spacing: 0;
}

.status-text {
  max-width: 460px;
  color: var(--muted);
  word-break: break-word;
}

.status-text.error {
  color: var(--danger);
}

.empty-row td {
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(360px, calc(100% - 40px));
  padding: 12px 14px;
  border-radius: 8px;
  background: #17211e;
  color: white;
  box-shadow: var(--shadow);
  transform: translateY(20px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 860px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }

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

  textarea {
    min-height: 230px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .topbar,
  .input-panel,
  .settings-panel,
  .results-panel {
    padding: 14px;
  }

  .actions,
  .results-head {
    display: grid;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
