:root {
  --bg: #fbf8f2;
  --bg-deep: #efe4d0;
  --panel: rgba(255, 255, 255, 0.75);
  --text: #1c2430;
  --muted: #5b6777;
  --accent: #0f7a65;
  --accent-2: #d16c2f;
  --line: rgba(28, 36, 48, 0.12);
  --shadow: 0 20px 45px rgba(22, 30, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% -10%, rgba(209, 108, 47, 0.18), transparent 35%),
    radial-gradient(circle at 90% 0%, rgba(15, 122, 101, 0.2), transparent 30%),
    linear-gradient(165deg, var(--bg) 0%, var(--bg-deep) 100%);
}

.bg-shape {
  position: fixed;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(30px);
  opacity: 0.4;
}

.bg-shape-1 {
  width: 340px;
  height: 340px;
  background: #d16c2f;
  left: -140px;
  top: 35vh;
}

.bg-shape-2 {
  width: 280px;
  height: 280px;
  background: #0f7a65;
  right: -100px;
  top: 5vh;
}

.layout {
  width: min(1140px, 94vw);
  margin: 3rem auto;
  display: grid;
  gap: 1rem;
  position: relative;
  z-index: 2;
}

.hero {
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.62));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 1.4rem 1.5rem;
}

.eyebrow {
  margin: 0;
  letter-spacing: 0.08em;
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--accent);
}

h1 {
  margin: 0.3rem 0 0.5rem;
  font-size: clamp(1.45rem, 2.8vw, 2.3rem);
}

h2 {
  margin: 0 0 0.9rem;
  font-size: 1.05rem;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}

.section-head h2 {
  margin: 0;
}

.hold-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.38rem;
  color: var(--muted);
  font-size: 0.77rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  user-select: none;
}

.hold-toggle input {
  width: 16px;
  height: 16px;
}

.section-tools {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}

.mini-btn {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 0.42rem 0.58rem;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  font-size: 0.76rem;
  font-family: "IBM Plex Mono", monospace;
  cursor: pointer;
}

.mini-btn:hover {
  border-color: rgba(15, 122, 101, 0.5);
  color: var(--accent);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(16, 21, 29, 0.56);
  display: grid;
  place-items: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.modal.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: min(920px, 96vw);
  max-height: 84vh;
  overflow: auto;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 24px 70px rgba(20, 27, 38, 0.35);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.95rem 1rem 0.7rem;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 0.85rem 1rem 1rem;
}

.ref-note {
  margin: 0 0 0.75rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.ref-search-wrap {
  display: grid;
  gap: 0.65rem;
}

.ref-search {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.52rem 0.62rem;
  font-size: 0.9rem;
  font-family: "IBM Plex Mono", monospace;
  background: #fff;
}

.ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}

.ref-table th,
.ref-table td {
  border: 1px solid var(--line);
  padding: 0.45rem 0.5rem;
  text-align: left;
}

.ref-table th {
  background: rgba(15, 122, 101, 0.09);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ref-row {
  cursor: pointer;
}

.ref-row:hover,
.ref-row:focus {
  outline: none;
  background: rgba(15, 122, 101, 0.09);
}

.hero p:last-child {
  margin-bottom: 0;
  max-width: 76ch;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(7px);
  padding: 1.2rem;
}

.panel.hold-active {
  border-color: rgba(15, 122, 101, 0.44);
  box-shadow: 0 20px 45px rgba(22, 30, 42, 0.08), 0 0 0 2px rgba(15, 122, 101, 0.16);
}

.app-notice {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 180;
  max-width: min(460px, 92vw);
  padding: 0.62rem 0.72rem;
  border-radius: 11px;
  border: 1px solid rgba(28, 36, 48, 0.2);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 14px 30px rgba(20, 27, 38, 0.22);
  color: var(--text);
  font-size: 0.84rem;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.app-notice.show {
  opacity: 1;
  transform: translateY(0);
}

.head-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.9rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
}

.project-links {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
}

.head-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-left: auto;
}

.lang-label {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.lang-label select {
  width: auto;
  min-width: 150px;
}

.project-links-label {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.project-links-list {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.project-links a {
  display: inline-flex;
  align-items: center;
  padding: 0.35rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  text-decoration: none;
  font-size: 0.76rem;
  transition: border-color 180ms ease, color 180ms ease, transform 180ms ease;
}

.project-links a:hover,
.project-links a:focus {
  color: var(--accent);
  border-color: rgba(15, 122, 101, 0.45);
  transform: translateY(-1px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(205px, 1fr));
  gap: 0.85rem;
}

label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 0.58rem 0.65rem;
  font-size: 0.95rem;
  font-family: "IBM Plex Mono", monospace;
  color: var(--text);
  background: rgba(255, 255, 255, 0.92);
}

input:focus,
select:focus {
  outline: 2px solid rgba(15, 122, 101, 0.34);
  outline-offset: 1px;
  border-color: var(--accent);
}

.check {
  margin-top: 0.95rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
}

.check input {
  width: 18px;
  height: 18px;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 0.8rem;
}

.tool-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.75rem;
}

.tool-card h3 {
  margin: 0 0 0.45rem;
  font-size: 0.95rem;
}

.tool-card .hint {
  margin: 0 0 0.65rem;
}

.tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.hint {
  margin: 0.95rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.viewer-panel .hint {
  margin-top: 0;
  margin-bottom: 0.75rem;
}

#coilViewer {
  position: relative;
  width: 100%;
  height: clamp(290px, 45vw, 470px);
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    radial-gradient(circle at 60% 30%, rgba(255, 255, 255, 0.88), rgba(236, 229, 214, 0.85));
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.viewer-legend {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  z-index: 8;
  display: grid;
  gap: 0.18rem;
  max-width: min(420px, calc(100% - 1.3rem));
  padding: 0.5rem 0.58rem;
  border-radius: 10px;
  border: 1px solid rgba(28, 36, 48, 0.2);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 22px rgba(20, 27, 38, 0.18);
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  line-height: 1.28;
  pointer-events: none;
}

.viewer-legend strong {
  font-size: 0.75rem;
}

.results {
  border: 1px solid rgba(15, 122, 101, 0.3);
}

.chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 0.75rem;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.84);
  padding: 0.62rem;
}

.chart-card h3 {
  margin: 0 0 0.4rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.chart-card-wide {
  grid-column: 1 / -1;
}

.chart-card canvas {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(28, 36, 48, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), rgba(239, 228, 208, 0.46));
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.7rem;
}

.result-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.85);
  padding: 0.65rem 0.75rem;
}

.result-item .name {
  display: block;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.result-item .value {
  display: block;
  margin-top: 0.25rem;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
  color: var(--text);
}

.author-panel {
  border-color: rgba(15, 122, 101, 0.28);
}

.author-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.8rem;
}

.author-item {
  display: grid;
  gap: 0.28rem;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.8);
}

.author-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.author-value {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.94rem;
  color: var(--text);
  text-decoration: none;
}

.author-value:hover,
.author-value:focus {
  color: var(--accent);
  text-decoration: underline;
}

.reveal {
  opacity: 0;
  transform: translateY(10px);
  animation: rise 620ms ease forwards;
  animation-delay: var(--d, 0s);
}

@keyframes rise {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 680px) {
  .layout {
    margin: 1rem auto 2rem;
  }

  .hero,
  .panel {
    border-radius: 16px;
    padding: 0.95rem;
  }

  .grid,
  .result-grid,
  .chart-grid {
    grid-template-columns: 1fr;
  }

  .section-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .section-tools {
    width: 100%;
    justify-content: space-between;
  }

  #coilViewer {
    height: 300px;
  }
}
