
:root {
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-2: #f5f8fa;
  --surface-3: #eaf1f5;
  --text: #14232e;
  --muted: #667985;
  --line: #d5e0e7;
  --primary: #0b6b8f;
  --accent: #13a49b;
  --success: #16845a;
  --warning: #b67813;
  --danger: #c44141;
  --shadow: 0 14px 34px rgba(16, 46, 64, 0.08);
  --sidebar: 330px;
}

[data-theme="dark"] {
  --bg: #0f171d;
  --surface: #18222a;
  --surface-2: #202c35;
  --surface-3: #273640;
  --text: #edf4f8;
  --muted: #9cafbc;
  --line: #33434e;
  --primary: #43abd0;
  --accent: #43d1c5;
  --success: #5cc993;
  --warning: #e0a146;
  --danger: #ef7676;
  --shadow: 0 16px 38px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Segoe UI", Inter, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 8% 0%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 27%),
    var(--bg);
}

a { color: inherit; }
button, input, select { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--surface) 93%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1500px;
  margin: 0 auto;
  min-height: 72px;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 11px;
  color: #fff;
  font-weight: 850;
  letter-spacing: .04em;
  background: linear-gradient(145deg, var(--primary), var(--accent));
}

.brand-title { font-weight: 800; line-height: 1.05; }
.brand-subtitle { color: var(--muted); font-size: 12px; margin-top: 3px; }

.actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.btn, .icon-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  transition: .18s ease;
}

.btn {
  padding: 10px 15px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-weight: 700;
}

.icon-btn { padding: 10px 12px; }
.btn:hover, .icon-btn:hover { border-color: var(--primary); transform: translateY(-1px); }
.btn-primary { color: #fff; background: var(--primary); border-color: var(--primary); }
.btn-secondary { background: var(--surface-2); }

.app-shell {
  max-width: 1500px;
  margin: 0 auto;
  min-height: calc(100vh - 73px);
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 73px;
  height: calc(100vh - 73px);
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  padding: 20px 15px 26px;
}

.sidebar-title {
  margin: 0 8px 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 5px 15px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.search-box input {
  width: 100%;
  padding: 11px 0;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
}

.nav-list {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  display: grid;
  grid-template-columns: 62px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  text-align: left;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
}

.nav-item:hover {
  border-color: var(--line);
  background: var(--surface-2);
}

.nav-item.active {
  color: var(--primary);
  border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
  background: color-mix(in srgb, var(--primary) 11%, var(--surface));
}

.nav-code {
  font-size: 12px;
  font-weight: 850;
  color: var(--primary);
}

.nav-name {
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-count {
  min-width: 26px;
  padding: 3px 7px;
  border-radius: 999px;
  text-align: center;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 11px;
  font-weight: 800;
}

.sidebar-separator {
  height: 1px;
  background: var(--line);
  margin: 16px 7px;
}

.content {
  min-width: 0;
  padding: 30px 28px 54px;
}

.panel, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.content-header {
  padding: 28px;
  margin-bottom: 24px;
}

.eyebrow {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .13em;
  font-size: 12px;
  font-weight: 850;
}

h1 {
  margin: 10px 0 13px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.03;
}

h2 { margin: 0 0 15px; font-size: 24px; }
h3 { margin: 0 0 10px; }

.lead, .content-header p, .calc-card p {
  color: var(--muted);
  line-height: 1.6;
}

.section { margin-top: 26px; }

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

.section-head p { margin: 0; color: var(--muted); }

.calc-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 17px;
}

.calc-card {
  padding: 21px;
  text-decoration: none;
  transition: .18s ease;
}

.calc-card:hover {
  transform: translateY(-2px);
  border-color: var(--primary);
}

.badge {
  display: inline-flex;
  padding: 5px 8px;
  margin-bottom: 13px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: .04em;
}

.badge-universal {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}

.badge-system {
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 12%, var(--surface));
}

.empty {
  padding: 23px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  background: var(--surface);
}

.welcome-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 13px;
  margin-top: 20px;
}

.stat {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}

.stat strong {
  display: block;
  color: var(--primary);
  font-size: 25px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.page-container {
  max-width: 1260px;
  margin: 0 auto;
  padding: 32px 22px 54px;
}

.breadcrumb {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 14px;
}

.breadcrumb a {
  color: var(--primary);
  text-decoration: none;
}

.calc-layout {
  display: grid;
  grid-template-columns: .92fr 1.08fr;
  gap: 22px;
}

.form-panel, .result-panel { padding: 26px; }
.form-grid { display: grid; gap: 16px; }

.field label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 800;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 120px;
}

input, select {
  width: 100%;
  padding: 12px 13px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  outline: none;
}

input { border-radius: 9px 0 0 9px; }
select { border-left: 0; border-radius: 0 9px 9px 0; }
select.full { border-left: 1px solid var(--line); border-radius: 9px; }

.help {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

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

.result-hero {
  padding: 24px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--primary) 15%, var(--surface)), var(--surface));
}

.result-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 850;
}

.result-value {
  margin: 10px 0 7px;
  font-size: clamp(43px, 7vw, 73px);
  font-weight: 880;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.result-unit {
  color: var(--primary);
  font-size: 21px;
  font-weight: 850;
}

.status {
  display: inline-flex;
  margin-top: 10px;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 800;
}

.status.ok { color: var(--success); }
.status.warn { color: var(--warning); }

.metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.metric small {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
}

.details {
  margin-top: 22px;
  display: grid;
  gap: 13px;
}

details {
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}

summary {
  padding: 16px 0;
  cursor: pointer;
  font-weight: 850;
}

.detail-body {
  padding: 0 0 18px;
  color: var(--muted);
  line-height: 1.65;
}

.formula {
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
  font: 20px "Cambria Math", "Times New Roman", serif;
}

.steps {
  color: var(--text);
  font-family: Consolas, monospace;
  white-space: pre-wrap;
  line-height: 1.75;
}

.error {
  display: none;
  margin-bottom: 14px;
  padding: 12px 14px;
  color: var(--danger);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, var(--line));
  border-radius: 9px;
  background: color-mix(in srgb, var(--danger) 9%, var(--surface));
}

.footer {
  margin-top: 34px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

@media (max-width: 1050px) {
  :root { --sidebar: 280px; }
  .calc-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: relative;
    top: 0;
    height: auto;
    max-height: 420px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .calc-layout { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .topbar-inner, .content, .page-container { padding-left: 14px; padding-right: 14px; }
  .calc-grid, .welcome-stats, .metrics { grid-template-columns: 1fr; }
  .brand-subtitle { display: none; }
}


/* Version 0.4 additions */
.project-context {
  display:flex; flex-direction:column; align-items:flex-end; gap:2px;
  min-width:180px; padding:6px 10px; border:1px solid var(--line);
  border-radius:9px; background:var(--surface-2);
}
.project-context strong { font-size:13px; }
.project-context span { color:var(--muted); font-size:11px; }
.home-grid { display:grid; grid-template-columns:minmax(0,1.35fr) minmax(280px,.65fr); gap:20px; }
.project-form { padding:27px; }
.project-side { padding:23px; }
.project-form-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px; }
.field-wide { grid-column:1/-1; }
.project-form-grid input { border-radius:9px; border-left:1px solid var(--line); }
.project-buttons { display:flex; gap:10px; flex-wrap:wrap; margin-top:21px; }
.workspace-status { display:grid; gap:12px; }
.workspace-row { padding-bottom:12px; border-bottom:1px solid var(--line); }
.workspace-row:last-child { border-bottom:0; padding-bottom:0; }
.workspace-row small { display:block; color:var(--muted); margin-bottom:4px; }
.workspace-row strong { display:block; overflow-wrap:anywhere; }
.status-dot { display:inline-block; width:9px; height:9px; margin-right:6px; border-radius:50%; background:var(--success); }
.save-message { min-height:18px; margin-top:9px; color:var(--muted); font-size:12px; }
.save-message.ok { color:var(--success); }
.save-message.warn { color:var(--warning); }
.about-card { padding:30px; }
.about-card p { color:var(--muted); line-height:1.7; }
.about-credit { margin:24px 0; padding:18px; border-left:4px solid var(--accent); border-radius:10px; background:var(--surface-2); }
.about-credit strong { display:block; margin-top:6px; font-size:20px; }
.footer-credit { margin-top:7px; font-weight:700; color:var(--text); }
.file-input-hidden { display:none; }
@media(max-width:920px){ .home-grid{grid-template-columns:1fr;} }
@media(max-width:620px){
  .project-form-grid{grid-template-columns:1fr;}
  .field-wide{grid-column:auto;}
  .project-context{display:none;}
}
