:root {
  --ink: #1e2428;
  --muted: #667078;
  --line: #d9dfdf;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --soft: #eef4f1;
  --accent: #0f766e;
  --accent-strong: #0a5c55;
  --warn: #b45309;
  --shadow: 0 18px 55px rgba(28, 38, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, 0.08), transparent 38%),
    linear-gradient(315deg, rgba(180, 83, 9, 0.08), transparent 34%),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

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

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.95;
}

h2 {
  font-size: 1rem;
}

.topbar-actions,
.result-heading,
.panel-heading,
.tabs,
.options-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.layout {
  display: grid;
  grid-template-columns: minmax(360px, 0.92fr) minmax(420px, 1.08fr);
  gap: 18px;
}

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

.input-panel {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 18px;
}

.panel-heading {
  justify-content: space-between;
}

#saveStatus {
  color: var(--muted);
  font-size: 0.82rem;
}

label {
  display: grid;
  gap: 7px;
  color: #344047;
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  padding: 11px 12px;
  font-weight: 600;
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.13);
}

.grid-two,
.grid-three {
  display: grid;
  gap: 12px;
}

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

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

.options-row {
  align-items: stretch;
  flex-wrap: wrap;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  background: var(--soft);
  font-weight: 700;
}

.check input {
  width: auto;
}

.output-panel {
  min-width: 0;
  overflow: hidden;
}

.tabs {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  background: rgba(238, 244, 241, 0.72);
}

.tab,
.ghost-button,
.primary-button,
.copy-button {
  border-radius: 7px;
  border: 1px solid var(--line);
  min-height: 40px;
  padding: 0 14px;
  background: #fff;
  color: var(--ink);
  font-weight: 800;
}

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

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

.ghost-button:hover,
.copy-button:hover,
.tab:hover {
  border-color: var(--accent);
}

.tab-panel {
  display: none;
  padding: 16px;
}

.tab-panel.active {
  display: grid;
  gap: 16px;
}

.result-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 16px;
}

.result-block.compact {
  background: var(--soft);
}

.result-heading {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.copy-target,
pre {
  color: #263137;
  line-height: 1.55;
}

.scorecard {
  color: #263137;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

#titleOutput {
  margin: 0;
  font-size: 1.06rem;
  font-weight: 800;
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family:
    ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    monospace;
  font-size: 0.9rem;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border: 1px solid rgba(15, 118, 110, 0.28);
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent-strong);
  padding: 5px 11px;
  font-size: 0.86rem;
  font-weight: 800;
}

#marginOutput {
  margin: 8px 0 0;
  color: #334047;
  font-weight: 700;
}

#toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(18px);
  opacity: 0;
  border-radius: 7px;
  background: var(--ink);
  color: #fff;
  padding: 11px 14px;
  font-weight: 800;
  transition: 180ms ease;
  pointer-events: none;
}

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

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

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

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

  .grid-two,
  .grid-three {
    grid-template-columns: 1fr;
  }

  .topbar-actions,
  .tabs {
    width: 100%;
  }

  .topbar-actions button,
  .tab {
    flex: 1;
  }
}
