:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --surface: #ffffff;
  --surface-strong: #eef2ea;
  --text: #1d2522;
  --muted: #66736d;
  --line: #d9dfd7;
  --accent: #0f766e;
  --accent-dark: #0b5e58;
  --warn: #b45309;
  --shadow: 0 16px 40px rgba(29, 37, 34, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
textarea {
  font: inherit;
}

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

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.25;
  font-weight: 750;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.topbar .privacy-note {
  color: var(--accent-dark);
  font-size: 14px;
}

.input-grid,
.result-grid,
.summary-grid {
  display: grid;
  gap: 16px;
}

.input-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.input-panel,
.result-panel,
.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  display: flex;
  flex-direction: column;
  min-height: 310px;
  overflow: hidden;
}

.input-panel span {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 700;
  color: var(--muted);
}

textarea {
  width: 100%;
  min-height: 260px;
  flex: 1;
  resize: vertical;
  border: 0;
  outline: none;
  padding: 16px;
  color: var(--text);
  background: transparent;
  line-height: 1.55;
}

textarea:focus {
  box-shadow: inset 0 0 0 2px rgba(15, 118, 110, 0.28);
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 18px 0;
}

button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
}

.primary-button {
  min-height: 44px;
  padding: 0 22px;
  background: var(--accent);
  color: white;
  font-weight: 750;
}

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

.ghost-button,
.text-button {
  background: transparent;
  color: var(--accent-dark);
  font-weight: 700;
}

.ghost-button {
  padding: 9px 12px;
  border: 1px solid var(--line);
}

.text-button {
  padding: 6px 8px;
}

.status-text {
  color: var(--muted);
  font-size: 14px;
}

.summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.metric {
  padding: 16px;
  box-shadow: none;
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metric strong {
  font-size: 26px;
  line-height: 1;
}

.metric.alert strong {
  color: var(--warn);
}

.result-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.result-panel {
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-strong);
  border-bottom: 1px solid var(--line);
}

h2 {
  font-size: 15px;
  font-weight: 750;
}

.result-list {
  min-height: 180px;
  max-height: 360px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: var(--text);
  background: var(--surface);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

.copy-helper {
  position: fixed;
  left: -9999px;
  top: 0;
}

@media (max-width: 820px) {
  .app {
    width: min(100vw - 24px, 680px);
    padding-top: 18px;
  }

  .topbar,
  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .input-grid,
  .result-grid,
  .summary-grid {
    grid-template-columns: 1fr;
  }

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