:root {
  --bg: #eef3f8;
  --panel: rgba(250, 253, 255, 0.84);
  --ink: #14202f;
  --muted: #66788f;
  --placeholder-ink: rgba(102, 120, 143, 0.45);
  --line: rgba(82, 108, 138, 0.16);
  --accent: #4f7db8;
  --accent-strong: #355f95;
  --accent-soft: #dce9f7;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-strong: #edf4fb;
  --shadow: 0 20px 60px rgba(47, 74, 105, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(96, 134, 181, 0.18), transparent 28%),
    radial-gradient(circle at right 20%, rgba(129, 168, 204, 0.12), transparent 24%),
    linear-gradient(135deg, #f6faff 0%, #ebf2fa 48%, #f4f8fd 100%);
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 0, 0, 0.04) 1px, transparent 1px);
  background-size: 6px 6px;
  mix-blend-mode: multiply;
}

.page {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 48px 24px 56px;
}

.hero {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 12px;
}

.hero h1 {
  margin: 0;
  max-width: 820px;
  font-size: clamp(40px, 7vw, 84px);
  line-height: 0.94;
  font-weight: 700;
}

.lead {
  max-width: 1380px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 24px;
  line-height: 1.6;
}

.disclaimer {
  max-width: 1280px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.75;
}

.workspace {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  gap: 20px;
}

.panel {
  backdrop-filter: blur(12px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.form-panel,
.result-panel {
  padding: 24px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.panel-head h2 {
  margin: 0;
  font-size: 28px;
}

.panel-head p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.result-toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 52px;
  flex: 0 0 auto;
}

textarea {
  width: 100%;
  min-height: 160px;
  margin-top: 22px;
  padding: 18px;
  border: 1px solid rgba(82, 108, 138, 0.16);
  border-radius: 22px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 17px;
  resize: vertical;
}

textarea:focus {
  outline: 2px solid rgba(79, 125, 184, 0.18);
  border-color: rgba(79, 125, 184, 0.3);
}

textarea::placeholder {
  color: var(--placeholder-ink);
}

.examples {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.example-chip {
  border: 1px solid rgba(29, 27, 24, 0.12);
  background: rgba(255, 255, 255, 0.65);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
}

.example-chip:hover {
  background: rgba(13, 92, 99, 0.08);
}

.actions {
  margin-top: 18px;
}

.history-block {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid rgba(29, 27, 24, 0.1);
}

.history-head h3 {
  margin: 0;
  font-size: 20px;
}

.history-head-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history-head p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.history-clear-button,
.history-delete-button {
  border: 1px solid rgba(82, 108, 138, 0.14);
  border-radius: 999px;
  background: rgba(250, 253, 255, 0.9);
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.history-clear-button {
  padding: 8px 14px;
  font-size: 14px;
}

.history-clear-button:disabled,
.history-delete-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.history-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.history-empty {
  margin: 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(250, 253, 255, 0.68);
  color: var(--placeholder-ink);
}

.history-item {
  position: relative;
}

.history-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid rgba(82, 108, 138, 0.12);
  border-radius: 20px;
  background: rgba(250, 253, 255, 0.76);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font: inherit;
  position: relative;
  z-index: 1;
}

.history-card:hover {
  border-color: rgba(79, 125, 184, 0.22);
  background: rgba(79, 125, 184, 0.08);
}

.history-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-delete-hint {
  color: var(--muted);
  font-size: 13px;
}

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

.history-delete-button {
  position: absolute;
  top: 50%;
  right: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0 0 2px;
  border-radius: 999px;
  font-size: 22px;
  line-height: 36px;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
  transform: translateY(-50%) scale(0.92);
  transition:
    opacity 140ms ease,
    transform 140ms ease,
    background-color 140ms ease,
    border-color 140ms ease;
}

.history-item:hover .history-delete-button,
.history-item:focus-within .history-delete-button {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) scale(1);
}

.history-delete-button:hover {
  border-color: rgba(79, 125, 184, 0.22);
  background: rgba(79, 125, 184, 0.08);
}

#submit-button,
.download-link,
.html-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0 20px;
  border-radius: 999px;
  border: none;
  text-decoration: none;
  cursor: pointer;
  font: inherit;
}

#submit-button,
.download-link {
  width: 100%;
  color: white;
  background: var(--accent);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.12);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    background-color 140ms ease;
}

#submit-button:hover,
.download-link:hover {
  background: #436fa8;
  box-shadow:
    inset 0 -1px 0 rgba(255, 255, 255, 0.12),
    0 10px 24px rgba(79, 125, 184, 0.2);
  transform: translateY(-1px);
}

#submit-button:disabled {
  opacity: 0.6;
  cursor: progress;
}

.status {
  margin: 18px 0 0;
  padding: 14px 16px;
  border-radius: 18px;
  font-size: 15px;
}

.status.idle {
  background: rgba(255, 255, 255, 0.66);
  color: var(--muted);
}

.status.loading {
  background: rgba(79, 125, 184, 0.12);
  color: var(--accent);
}

.status.success {
  background: rgba(79, 125, 184, 0.12);
  color: var(--accent-strong);
}

.status.error {
  background: rgba(120, 74, 148, 0.12);
  color: #5c4377;
}

.summary {
  margin-top: 20px;
  min-height: 96px;
  border-radius: 22px;
  border: 1px dashed rgba(82, 108, 138, 0.16);
  padding: 16px 18px;
  background: rgba(250, 253, 255, 0.56);
}

.summary.empty {
  display: grid;
  place-items: center;
  color: var(--placeholder-ink);
  text-align: center;
}

.summary-loading {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(100%, 620px);
  padding: 12px 0;
}

.summary-loading-mark {
  display: inline-flex;
  align-items: flex-end;
  gap: 10px;
  height: 44px;
}

.summary-loading-mark span {
  display: block;
  width: 12px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(79, 125, 184, 0.92), rgba(53, 95, 149, 0.82));
  box-shadow: 0 10px 18px rgba(79, 125, 184, 0.18);
  transform-origin: center bottom;
  animation: summary-bars 1.15s ease-in-out infinite;
}

.summary-loading-mark span:nth-child(1) {
  height: 18px;
  animation-delay: 0s;
}

.summary-loading-mark span:nth-child(2) {
  height: 34px;
  animation-delay: 0.14s;
}

.summary-loading-mark span:nth-child(3) {
  height: 24px;
  animation-delay: 0.28s;
}

.summary-loading-copy {
  max-width: 620px;
}

.summary-loading-copy strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
  letter-spacing: 0.04em;
}

.summary-loading-copy p {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.summary-grid {
  display: grid;
  gap: 12px;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 14px;
}

.company-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--muted);
}

.company-pill {
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(79, 125, 184, 0.08);
  border: 1px solid rgba(79, 125, 184, 0.12);
}

.html-link {
  color: var(--ink);
  background: rgba(250, 253, 255, 0.88);
  border: 1px solid rgba(82, 108, 138, 0.14);
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease,
    background-color 140ms ease,
    color 140ms ease;
}

.html-link:hover {
  color: var(--accent-strong);
  background: rgba(244, 249, 255, 0.98);
  border-color: rgba(79, 125, 184, 0.22);
  box-shadow: 0 10px 24px rgba(79, 125, 184, 0.14);
  transform: translateY(-1px);
}

.html-link:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(79, 125, 184, 0.12);
}

.html-link:focus-visible {
  outline: none;
  border-color: rgba(79, 125, 184, 0.28);
  box-shadow:
    0 0 0 4px rgba(79, 125, 184, 0.12),
    0 10px 24px rgba(79, 125, 184, 0.14);
}

.toolbar-link {
  width: auto;
  white-space: nowrap;
}

.viewer-shell {
  margin-top: 18px;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(82, 108, 138, 0.14);
  background: var(--surface-strong);
}

.viewer-shell.hidden {
  display: none;
}

#report-frame {
  width: 100%;
  height: 920px;
  border: none;
  background: var(--surface-strong);
}

@keyframes summary-bars {
  0%,
  100% {
    transform: scaleY(0.72);
    opacity: 0.58;
  }
  50% {
    transform: scaleY(1.18);
    opacity: 1;
  }
}

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

  #report-frame {
    height: 760px;
  }
}
