:root {
  --bg: #f2f4f7;
  --card: #ffffff;
  --primary: #1d4ed8;
  --primary-dark: #16327f;
  --accent: #f97316;
  --text: #1f2933;
  --muted: #64748b;
  --border: #e2e8f0;
  --danger: #dc2626;
  --success: #15803d;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.site-header {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  padding: 28px 0;
}
.header-inner { display: flex; align-items: center; }
.brand { display: flex; align-items: center; gap: 16px; }
.brand-icon { font-size: 40px; }
.brand h1 { margin: 0; font-size: 24px; }
.tagline { margin: 4px 0 0; color: rgba(255,255,255,0.85); font-size: 14px; }

/* Sections */
main { padding: 28px 0 60px; }
.section-title {
  font-size: 15px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 12px;
  font-weight: 700;
}

/* Shape selector */
.shape-selector { margin-bottom: 24px; }
.shape-tabs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
}
.shape-tab {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 8px;
  cursor: pointer;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: border-color .15s, background .15s, transform .1s;
}
.shape-tab:hover { border-color: var(--primary); transform: translateY(-1px); }
.shape-tab.active {
  border-color: var(--primary);
  background: #eff4ff;
  color: var(--primary-dark);
}
.shape-tab .icon { font-size: 24px; }

/* Grid layout */
.calc-grid {
  display: grid;
  grid-template-columns: 1.1fr 1.6fr 1.1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .calc-grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
}

.diagram-holder {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 160px;
  background: #f8fafc;
  border-radius: 8px;
  padding: 12px;
}
.diagram-holder svg { max-width: 100%; height: auto; }
.shape-note { color: var(--muted); font-size: 13px; margin: 12px 0 0; }

/* Form */
.field-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field .opt { font-weight: 400; text-transform: none; color: #94a3b8; }
input[type="number"], select {
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input[type="number"]:focus, select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.btn {
  border: none;
  border-radius: 8px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s, opacity .15s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #ea580c; }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Result */
.result-box {
  border-radius: 10px;
  padding: 16px;
  background: #f8fafc;
  border: 1.5px dashed var(--border);
  min-height: 140px;
}
.result-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; text-align: center; }
.result-box.filled {
  background: #ecfdf5;
  border: 1.5px solid #a7f3d0;
  display: block;
}
.result-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid rgba(0,0,0,0.06);
  font-size: 14px;
}
.result-row:last-child { border-bottom: none; }
.result-row .label { color: var(--muted); }
.result-row .value { font-weight: 700; }
.result-row.total .value { color: var(--primary-dark); font-size: 18px; }
.result-row.error { color: var(--danger); font-weight: 600; }

/* History */
.history-section { margin-top: 32px; }
.history-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-empty { color: var(--muted); font-size: 14px; }
.history-item {
  background: var(--card);
  border-radius: 10px;
  box-shadow: var(--shadow);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  flex-wrap: wrap;
}
.history-item .meta { color: var(--muted); }
.history-item .weight { font-weight: 700; color: var(--primary-dark); }
.history-item .del {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}

.disclaimer {
  margin-top: 30px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* Footer */
.site-footer {
  background: #0f172a;
  color: #94a3b8;
  padding: 16px 0;
  font-size: 12px;
  text-align: center;
}
