:root {
  --bg: #f5f1e8;
  --panel: rgba(255, 252, 245, 0.88);
  --ink: #1d1a16;
  --muted: #615749;
  --line: rgba(68, 51, 34, 0.18);
  --accent: #9c2f12;
  --accent-soft: #f0c7b8;
  --secondary: #244c5a;
  --safe: #2f7d4d;
  --warn: #c17e19;
  --danger: #b33a27;
  --shadow: 0 24px 60px rgba(48, 33, 20, 0.12);
  --hc-header-height: 88px;
  --hc-footer-height: 56px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(217, 148, 102, 0.22), transparent 28%),
    radial-gradient(circle at bottom right, rgba(63, 109, 121, 0.18), transparent 30%),
    linear-gradient(180deg, #f6f1e8, #efe6d7 56%, #eadfcf);
  font: 16px/1.5 "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

.hc-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--hc-header-height);
  z-index: 1001;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 1px 8px rgba(60,64,67,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 1.25rem;
  box-sizing: border-box;
  overflow: hidden;
}

.hc-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1 1 auto;
  max-width: 100%;
  overflow: hidden;
}

.hc-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(156, 47, 18, 0.10) 0%, rgba(240, 199, 184, 0.95) 100%);
  border: 1px solid rgba(156, 47, 18, 0.18);
  box-shadow: 0 1px 4px rgba(60,64,67,0.16);
  flex-shrink: 0;
}

.hc-logo-glyph {
  color: var(--accent);
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.hc-header-text {
  min-width: 0;
  min-height: 100%;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.hc-title-line {
  display: flex;
  align-items: baseline;
  gap: 0.65rem;
  flex-wrap: wrap;
  min-width: 0;
}

.hc-header h1 {
  font-family: 'Google Sans', 'Roboto', sans-serif;
  font-size: 1.08rem;
  font-weight: 700;
  color: var(--ink);
  margin: 0;
  letter-spacing: -0.02em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hc-tagline {
  font-size: 0.83rem;
  color: var(--muted);
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hc-header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  min-width: 0;
}

.hc-suite-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.85rem;
  border-radius: 14px;
  background: linear-gradient(135deg, #F5F9FF 0%, #E8F0FE 100%);
  border: 1px solid #C5D9FB;
  box-shadow: 0 1px 4px rgba(60,64,67,0.16);
  min-width: 0;
  text-decoration: none !important;
  transition: transform 110ms ease, box-shadow 130ms ease, background 130ms ease;
}

.hc-suite-pill:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(60,64,67,0.18);
  background: linear-gradient(135deg, #EEF5FF 0%, #DCEBFF 100%);
}

.hc-suite-pill:visited {
  color: inherit;
}

.hc-suite-label {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #4285F4;
  white-space: nowrap;
  text-transform: uppercase;
}

code {
  padding: 0.05rem 0.35rem;
  border-radius: 0.35rem;
  background: rgba(36, 76, 90, 0.08);
}

.page-shell {
  width: min(1520px, calc(100vw - 32px));
  margin: 0 auto;
  padding: calc(var(--hc-header-height) + 32px) 0 calc(var(--hc-footer-height) + 32px);
}

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

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

.controls {
  padding: 24px;
  position: sticky;
  top: calc(var(--hc-header-height) + 18px);
  align-self: start;
}

.results {
  padding: 24px;
}

h2,
h3 {
  margin: 0 0 12px;
}

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

.info-button {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(36, 76, 90, 0.18);
  background: rgba(36, 76, 90, 0.08);
  color: var(--secondary);
  font-weight: 800;
  font-size: 1rem;
}

.help-panel {
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid rgba(36, 76, 90, 0.14);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
}

.help-panel p {
  margin: 0 0 8px;
}

.help-panel p:last-child {
  margin-bottom: 0;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.wide {
  grid-column: 1 / -1;
}

.field span,
.config-table th {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

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

input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(68, 51, 34, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.table-wrap {
  overflow-x: auto;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
}

.config-table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.config-table th,
.config-table td,
.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.config-table tr:last-child td,
.data-table tr:last-child td {
  border-bottom: none;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}

button {
  border: none;
  border-radius: 999px;
  padding: 11px 16px;
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.primary {
  background: linear-gradient(135deg, var(--accent), #c25435);
  color: white;
}

.secondary {
  background: rgba(36, 76, 90, 0.1);
  color: var(--secondary);
}

.status-line,
.muted {
  color: var(--muted);
}

.error-box {
  margin-top: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(179, 58, 39, 0.1);
  color: var(--danger);
  white-space: pre-wrap;
}

.hidden {
  display: none;
}

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

.best-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.best-card {
  padding: 16px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(247, 240, 229, 0.92));
}

.best-card h3 {
  margin-bottom: 8px;
}

.best-card .pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.pill.safe {
  background: rgba(47, 125, 77, 0.14);
  color: var(--safe);
}

.pill.warn {
  background: rgba(193, 126, 25, 0.14);
  color: var(--warn);
}

.pill.danger {
  background: rgba(179, 58, 39, 0.14);
  color: var(--danger);
}

.best-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  margin: 12px 0 0;
}

.best-card dt {
  color: var(--muted);
}

.best-card dd {
  margin: 0;
  font-weight: 600;
}

.plot-grid,
.table-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.plot-card,
.table-card {
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
}

.plot {
  min-height: 420px;
}

.plot-tall {
  min-height: 580px;
}

.hc-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--hc-footer-height);
  background: rgba(248, 249, 250, 0.96);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid #E0E0E0;
  box-shadow: 0 -1px 8px rgba(60,64,67,0.07);
  z-index: 9999;
  box-sizing: border-box;
}

.hc-footer-inner {
  height: 100%;
  padding: 0 1.6rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  font-family: 'Roboto', 'Google Sans', sans-serif;
}

.hc-footer-suite {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.hc-footer-name {
  font-size: 0.83rem;
  font-weight: 700;
  color: #4285F4;
  white-space: nowrap;
}

.hc-footer-slogan {
  font-size: 0.67rem;
  color: #5F6368;
  white-space: nowrap;
  font-style: italic;
}

.hc-footer-author {
  font-size: 0.78rem;
  color: #5F6368;
  white-space: nowrap;
  margin-left: auto;
}

.hc-footer-github {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0.44rem 1.05rem;
  border-radius: 999px;
  background: #1e2330;
  color: #FFFFFF !important;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none !important;
  transition: background 130ms ease, transform 110ms ease, box-shadow 130ms ease;
  box-shadow: 0 1px 4px rgba(0,0,0,0.20);
  flex-shrink: 0;
  font-family: 'Google Sans', 'Roboto', sans-serif;
}

.hc-footer-github svg { flex-shrink: 0; }
.hc-footer-github:hover { background: #2d3348; transform: translateY(-1px); box-shadow: 0 3px 9px rgba(0,0,0,0.25); }

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

  .controls {
    position: static;
  }

  :root {
    --hc-header-height: 80px;
  }

  .hc-header {
    padding: 0 1rem;
  }

  .hc-logo {
    width: 40px;
    height: 40px;
  }

  .hc-header h1 {
    font-size: 0.98rem;
  }

  .hc-tagline {
    font-size: 0.76rem;
  }

  .hc-suite-label {
    font-size: 0.72rem;
    white-space: normal;
  }
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 18px, 100%);
    padding-top: calc(var(--hc-header-height) + 18px);
  }

  .controls,
  .results {
    padding: 18px;
    border-radius: 22px;
  }

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

@media (max-width: 680px) {
  :root {
    --hc-header-height: 94px;
    --hc-footer-height: 76px;
  }

  .hc-header {
    align-items: center;
    padding: 0 0.8rem;
  }

  .hc-logo {
    width: 36px;
    height: 36px;
  }

  .hc-logo-glyph {
    font-size: 0.68rem;
  }

  .hc-title-line {
    align-items: flex-start;
    gap: 0.2rem;
    flex-direction: column;
    flex-wrap: nowrap;
  }

  .hc-header h1 {
    font-size: 0.9rem;
    white-space: normal;
  }

  .hc-tagline {
    font-size: 0.72rem;
    white-space: normal;
  }

  .hc-footer-inner {
    padding: 0.45rem 0.9rem;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 0.35rem 1rem;
  }

  .hc-footer-author { margin-left: 0; }
  .hc-footer-github { margin-left: auto; }

  .hc-suite-pill {
    padding: 0.45rem 0.65rem;
  }

  .hc-suite-label {
    font-size: 0.68rem;
  }
}
