:root {
  color-scheme: light;
  --ink: #1d2430;
  --muted: #5b6d7e;
  --line: #d9e0e8;
  --panel: #ffffff;
  --bg: #eef2f5;
  --accent: #0f766e;
  --accent-dark: #0b5d57;
  --warm: #b45f35;
  --gold: #d8a13a;
  --blue: #315a8c;
  --shadow: 0 18px 50px rgba(26, 37, 55, 0.14);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

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

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

img,
svg {
  max-width: 100%;
}

.shell {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 16px 30px;
}

.page-header {
  margin-bottom: 16px;
}

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  min-height: calc(100vh - 90px);
}

.input-panel,
.output-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(217, 224, 232, 0.95);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.input-panel {
  padding: 18px;
  position: static;
}

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

.brand-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 14px;
  align-items: start;
}

.mark {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--blue));
  position: relative;
  overflow: hidden;
}

.mark::before {
  content: "";
  position: absolute;
  inset: 12px 8px auto;
  height: 14px;
  background: white;
  clip-path: polygon(50% 0, 100% 55%, 100% 100%, 0 100%, 0 55%);
}

.mark span {
  position: absolute;
  width: 20px;
  height: 3px;
  left: 10px;
  bottom: 10px;
  background: rgba(255, 255, 255, 0.78);
}

.eyebrow {
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-dark);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.5rem, 2vw, 2rem);
  line-height: 1.08;
}

h2 {
  font-size: 1.1rem;
}

.brand-row p,
.output-toolbar p,
.note,
.empty-state p {
  color: var(--muted);
  line-height: 1.55;
}

.brand-row p {
  font-size: 0.94rem;
  margin-top: 8px;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: block;
  font-size: 0.82rem;
  font-weight: 800;
  color: #344255;
  margin-bottom: 6px;
}

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

textarea {
  resize: vertical;
  padding: 14px;
  line-height: 1.45;
  min-height: 120px;
}

input,
select {
  height: 48px;
  padding: 0 14px;
}

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

.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.suffix-field {
  position: relative;
}

.suffix-field input {
  padding-right: 40px;
}

.suffix-field span {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-weight: 700;
}

button {
  width: 100%;
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
  letter-spacing: 0.01em;
}

#run-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--accent);
  color: white;
}

#run-button:hover {
  background: var(--accent-dark);
}

.secondary {
  width: auto;
  padding: 0 14px;
  min-height: 42px;
  background: #f8fafc;
  border: 1px solid rgba(217, 224, 232, 0.9);
  color: var(--ink);
}

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

.output-toolbar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.progress {
  height: 6px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  overflow: hidden;
  margin-bottom: 18px;
}

.progress div {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  animation: loadProgress 1.8s linear infinite;
}

@keyframes loadProgress {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.result {
  min-height: 320px;
}

.result.empty {
  display: grid;
  place-items: center;
}

.empty-state {
  text-align: center;
  padding: 28px 10px;
}

.property-visual {
  display: inline-grid;
  gap: 16px;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(49, 90, 140, 0.08));
  border-radius: 22px;
  padding: 24px 20px;
}

.property-visual .roof,
.property-visual .house,
.property-visual .chart {
  display: block;
}

.property-visual .roof {
  width: 80px;
  height: 14px;
  margin: 0 auto;
  background: var(--accent);
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}

.property-visual .house {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.property-visual .house span {
  display: block;
  height: 16px;
  border-radius: 10px;
  background: rgba(15, 118, 110, 0.18);
}

.property-visual .chart {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.property-visual .chart i {
  width: 10px;
  border-radius: 999px;
  background: var(--accent);
  height: 24px;
}

.sources-card {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid rgba(217, 224, 232, 0.9);
}

.sources-card h3 {
  font-size: 1rem;
  margin-bottom: 12px;
}

.sources-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.sources-card li a {
  color: var(--accent-dark);
  text-decoration: none;
}

.note {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  background: #f4f7fb;
  color: var(--muted);
  font-size: 0.95rem;
}

.code,
code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

@media (min-width: 820px) {
  .shell {
    padding: 24px;
  }

  .workspace {
    grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
    min-height: calc(100vh - 70px);
  }

  .input-panel {
    position: sticky;
    top: 24px;
  }

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

  .toolbar-actions {
    justify-content: flex-end;
  }
}

@media (min-width: 1080px) {
  .shell {
    padding: 30px;
  }
}

.button-icon {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
  position: relative;
}

.button-icon::after {
  content: "";
  position: absolute;
  width: 8px;
  height: 2px;
  right: -7px;
  bottom: -3px;
  background: currentColor;
  transform: rotate(45deg);
}

.note {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}

code {
  background: #eef4f3;
  border: 1px solid #d3e5e2;
  border-radius: 6px;
  padding: 1px 5px;
}

.output-toolbar {
  min-height: 86px;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 252, 253, 0.88);
}

h2 {
  font-size: 1.15rem;
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.secondary {
  min-width: 76px;
  background: #eef2f5;
  color: #344255;
  border: 1px solid var(--line);
}

.secondary:hover {
  background: #e4ebf0;
}

.progress {
  height: 4px;
  background: #e4ebf0;
  overflow: hidden;
}

.progress div {
  width: 38%;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold), var(--warm));
  animation: loading 1.2s ease-in-out infinite alternate;
}

@keyframes loading {
  from { transform: translateX(-30%); }
  to { transform: translateX(190%); }
}

.result {
  padding: 26px;
  max-width: 980px;
  min-height: calc(100vh - 190px);
  overflow-x: auto;
  line-height: 1.58;
}

.result.empty {
  max-width: none;
  display: grid;
  place-items: center;
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 18px;
  max-width: 390px;
  text-align: center;
}

.property-visual {
  width: 230px;
  height: 170px;
  position: relative;
}

.roof {
  position: absolute;
  width: 126px;
  height: 58px;
  left: 28px;
  top: 40px;
  background: var(--warm);
  clip-path: polygon(50% 0, 100% 70%, 88% 70%, 88% 100%, 12% 100%, 12% 70%, 0 70%);
}

.house {
  position: absolute;
  width: 112px;
  height: 72px;
  left: 35px;
  top: 88px;
  border-radius: 8px;
  background: #ffffff;
  border: 2px solid #c7d1dc;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 15px;
}

.house span {
  background: #dbe9ef;
  border-radius: 4px;
}

.chart {
  position: absolute;
  right: 20px;
  bottom: 10px;
  width: 78px;
  height: 96px;
  border-radius: 8px;
  background: #233244;
  padding: 14px 10px;
  display: flex;
  align-items: end;
  gap: 7px;
}

.chart i {
  display: block;
  width: 10px;
  border-radius: 3px 3px 0 0;
  background: var(--gold);
}

.chart i:nth-child(1) { height: 30%; }
.chart i:nth-child(2) { height: 56%; background: #60a5a0; }
.chart i:nth-child(3) { height: 76%; }
.chart i:nth-child(4) { height: 46%; background: #88a8cf; }

.result h1 {
  font-size: clamp(1.7rem, 2vw, 2.25rem);
  margin-bottom: 10px;
}

.result h2 {
  font-size: 1.35rem;
  margin: 28px 0 10px;
}

.result h3 {
  font-size: 1.08rem;
  margin: 22px 0 8px;
}

.result p {
  margin: 10px 0;
}

.result blockquote {
  margin: 18px 0;
  padding: 12px 15px;
  border-left: 4px solid var(--warm);
  background: #fff7f2;
  color: #66361e;
}

.result table {
  width: 100%;
  border-collapse: collapse;
  margin: 15px 0 20px;
  font-size: 0.94rem;
}

.result th,
.result td {
  border: 1px solid var(--line);
  padding: 9px 10px;
  vertical-align: top;
}

.result th {
  background: #edf4f3;
  text-align: left;
}

.result tr:nth-child(even) td {
  background: #fbfcfd;
}

.result ul {
  padding-left: 22px;
}

.result a {
  color: var(--accent-dark);
}

.sources-card {
  margin: 0 26px 26px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.sources-card h3 {
  margin-bottom: 10px;
}

.sources-card ul {
  margin: 0;
  padding-left: 20px;
}

.sources-card a {
  color: var(--accent-dark);
}

@media (max-width: 980px) {
  .shell {
    padding: 12px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .input-panel {
    position: static;
  }

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

@media (max-width: 560px) {
  .form-grid,
  .brand-row {
    grid-template-columns: 1fr;
  }

  .mark {
    width: 42px;
    height: 42px;
  }

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

  .toolbar-actions {
    width: 100%;
  }

  .toolbar-actions button {
    flex: 1;
  }
}

.activity-log {
  margin: 0 0 4px;
  background: #1a2535;
  max-height: 140px;
  overflow-y: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.75rem;
  line-height: 1.5;
  scrollbar-width: thin;
  scrollbar-color: #3a4f68 transparent;
}

.activity-log .log-entry {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 18px;
  color: #8bbcb5;
}

.activity-log .log-entry:first-child { padding-top: 10px; }
.activity-log .log-entry:last-child { padding-bottom: 10px; }

.activity-log .log-icon {
  flex-shrink: 0;
  color: #4da8a0;
  display: inline-block;
  animation: spin 1.4s linear infinite;
}

.activity-log .log-query {
  color: #c4e0dc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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