:root {
  color-scheme: light;
  --bg: #eef2f6;
  --surface: #ffffff;
  --surface-soft: #f7f9fb;
  --ink: #1d2733;
  --muted: #637083;
  --line: #d9e0e8;
  --accent: #146c94;
  --accent-strong: #0d5677;
  --accent-soft: #e7f4f8;
  --danger: #b42318;
  --success: #157347;
  --shadow: 0 18px 45px rgba(33, 47, 69, 0.11);
}

* {
  box-sizing: border-box;
}

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

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

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

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

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 32px;
  line-height: 1.05;
  font-weight: 760;
}

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

.market-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

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

.input-panel {
  display: grid;
  gap: 18px;
  padding: 18px;
}

.field-grid {
  display: grid;
  grid-template-columns: minmax(240px, 0.7fr) minmax(0, 1.3fr);
  gap: 14px;
}

label,
fieldset {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

label span,
legend {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--ink);
  outline: none;
}

input,
select {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 116px;
  resize: vertical;
  padding: 12px;
  line-height: 1.48;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(20, 108, 148, 0.14);
}

.choice-grid {
  display: grid;
  gap: 8px;
}

.timeframe-grid {
  grid-template-columns: repeat(auto-fit, minmax(62px, 1fr));
}

.indicator-grid {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

.history-controls {
  display: flex;
  align-items: end;
  gap: 12px;
}

.segmented-control {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(94px, 1fr));
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

.segmented-control label {
  position: relative;
  display: block;
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: grid;
  place-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 720;
}

.segmented-control input:checked + span {
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: 0 1px 4px rgba(33, 47, 69, 0.14);
}

.segmented-control input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.history-date {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(126px, 0.7fr);
  gap: 8px;
  width: min(100%, 360px);
}

.history-date[hidden] {
  display: none;
}

.check-option {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid #c8dae4;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 720;
  cursor: pointer;
  user-select: none;
}

.check-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 42px;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 720;
}

#generate-button {
  padding: 0 16px;
  background: var(--accent);
  color: #ffffff;
}

#generate-button:hover {
  background: var(--accent-strong);
}

#generate-button:disabled,
.copy-action:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.copy-action {
  min-width: 74px;
  padding: 0 12px;
  border-color: var(--line);
  background: var(--surface-soft);
  color: var(--ink);
}

.copy-action:not(:disabled):hover {
  border-color: var(--accent);
  color: var(--accent-strong);
}

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

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

.status.success {
  color: var(--success);
}

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

.metrics-panel,
.prompt-panel {
  min-height: 430px;
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 40px;
  margin-bottom: 12px;
}

h2 {
  font-size: 17px;
  line-height: 1.2;
}

#last-updated {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.metrics {
  display: grid;
  gap: 10px;
  margin: 0;
}

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

.metric-group-title {
  padding: 2px 0;
  color: var(--ink);
  font-size: 14px;
  font-weight: 780;
}

.metric-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  min-height: 44px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
}

dt {
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 760;
}

#prompt-output {
  min-height: 352px;
  height: calc(100% - 52px);
  font-family:
    "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

@media (max-width: 860px) {
  .shell {
    width: min(100% - 20px, 760px);
    padding: 14px 0;
  }

  .topbar,
  .actions,
  .history-controls,
  .section-head {
    align-items: flex-start;
  }

  .topbar,
  .output-grid,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .output-grid {
    display: grid;
  }

  .history-controls {
    flex-direction: column;
  }

  .segmented-control,
  .history-date {
    width: 100%;
  }

  .history-date {
    grid-template-columns: 1fr;
  }

  .metrics-panel,
  .prompt-panel {
    min-height: auto;
  }

  .section-head {
    flex-direction: column;
  }

  .copy-action {
    width: 100%;
  }
}
