/* =========================================================
   Colors & fonts
   ========================================================= */
:root {
  --paper: #f4f3ef;      /* page background */
  --white: #ffffff;
  --ink: #1d2024;        /* main text */
  --ink-2: #5b6068;      /* secondary text */
  --line: #e1dfd8;       /* light borders */
  --line-dark: #bdbab1;  /* input borders */
  --accent: #d9480f;     /* safety orange */
  --accent-soft: #fdf0e9;
  --hover: #f8f7f4;
  --error: #b42318;

  --sans: "IBM Plex Sans", "Plex Sans Fallback", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;

  --radius: 3px;
  --topbar-h: 52px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
  -webkit-tap-highlight-color: transparent;
}

body.no-scroll { overflow: hidden; }

.mono { font-family: var(--mono); }

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 16px;
}

button { font: inherit; color: inherit; }

/* =========================================================
   Top bar
   ========================================================= */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--ink);
  color: #c9ccd1;
  border-bottom: 3px solid var(--accent);
  padding-top: env(safe-area-inset-top);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--topbar-h);
}

.logo {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 17px;
  color: #fff;
  text-decoration: none;
}
.logo span { color: var(--accent); }

.topnav { display: flex; gap: 20px; font-size: 14px; }
.topnav a { color: #c9ccd1; text-decoration: none; padding: 4px 0; }
.topnav a:hover { color: #fff; }
.topnav a.active { color: #fff; border-bottom: 1px solid var(--accent); }

/* =========================================================
   Page title
   ========================================================= */
.page-title { padding: 26px 0 18px; }
.page-title h1 { margin: 0 0 2px; font-size: 24px; font-weight: 600; }
.page-title p { margin: 0; color: var(--ink-2); }

/* =========================================================
   Layout
   ========================================================= */
.layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

/* Grid items may shrink below their content width (e.g. a scrolling toolbar) */
.layout > * { min-width: 0; }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

/* =========================================================
   Inputs & buttons
   ========================================================= */
input {
  width: 100%;
  height: 40px;
  padding: 0 10px;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  -webkit-appearance: none;
  appearance: none;
}

input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent);
}

input.invalid { border-color: var(--error); background: #fef3f2; }

/* Hide number arrows, they are hard to click and waste space */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type="number"] { -moz-appearance: textfield; }

.btn {
  height: 34px;
  padding: 0 14px;
  font-size: 13px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}

.btn-ghost {
  background: none;
  border: 1px solid var(--line-dark);
  color: var(--ink-2);
}
.btn-ghost:hover { color: var(--ink); border-color: var(--ink-2); }

/* WhatsApp green, so it is easy to spot */
.btn-whatsapp { color: #128c4b; border-color: #8fd1ad; }
.btn-whatsapp:hover { color: #0b6b38; border-color: #128c4b; }

.btn-primary {
  height: 44px;
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #fff;
  font-weight: 500;
  font-size: 14px;
}
.btn-primary:hover:not(:disabled) { background: #000; }
.btn-primary:disabled { opacity: 0.3; cursor: not-allowed; }

.btn:focus-visible,
.picker-trigger:focus-visible,
.picker-option:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* =========================================================
   Picker (dropdown)  —  see picker.js
   ========================================================= */
.pickers {
  display: grid;
  grid-template-columns: 1fr 1fr 170px;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.picker { position: relative; min-width: 0; }

.picker-label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 4px;
}

.picker-trigger {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 48px;
  padding: 0 12px;
  background: var(--white);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  text-align: left;
  cursor: pointer;
}
.picker-trigger:hover { border-color: var(--ink-2); }
.picker.open .picker-trigger { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

.picker-value {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.picker-value svg,
.picker-option svg:not(.picker-check) { width: 24px; height: 24px; flex-shrink: 0; }

.picker-item-label {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.picker-item-meta {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  white-space: nowrap;
}

.chevron { width: 16px; height: 16px; flex-shrink: 0; color: var(--ink-2); transition: transform 0.15s; }
.picker.open .chevron { transform: rotate(180deg); }

/* The panel that opens (desktop: popover under the button) */
.picker-panel {
  position: absolute;
  z-index: 30;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  min-width: 240px;
  background: var(--white);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(29, 32, 36, 0.12);
  overflow: hidden;
}

/* Header with handle + title is only used in the mobile sheet */
.sheet-head { display: none; }

/* The density is shown in its own field, not in the material button */
#material-picker .picker-trigger .picker-item-meta { display: none; }

/* Density field next to the material dropdown */
.density-field { position: relative; margin: 0; min-width: 0; }
.density-field label { font-size: 12px; color: var(--ink-2); margin-bottom: 4px; }
.density-row { display: flex; flex-wrap: wrap; gap: 4px 6px; align-items: center; }
.density-row .input-unit { flex: 1; min-width: 0; }
.density-field input { height: 48px; padding-right: 50px; }
.density-field input.edited { border-color: var(--accent); background: var(--accent-soft); }
/* Desktop: small reset link on the label line, so the input keeps its full width */
.density-reset {
  position: absolute;
  top: 0;
  right: 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 18px;
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  white-space: nowrap;
}
.density-reset:hover { text-decoration: underline; }

/* The material list is long and has densities, give it more room */
#material-picker .picker-panel { left: auto; min-width: 340px; }
#material-picker .picker-list { max-height: 400px; }

.picker-search {
  height: 38px;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-family: var(--sans);
  padding: 0 12px;
}
.picker-search:focus { box-shadow: none; border-color: var(--line); background: var(--hover); }

.picker-list {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.picker-group {
  padding: 10px 12px 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-2);
}

.picker-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
}
.picker-option:hover,
.picker-option:focus-visible { background: var(--hover); outline-offset: -2px; }
.picker-option .picker-item-label { font-weight: 400; }
.picker-option[aria-selected="true"] .picker-item-label { font-weight: 600; }

.picker-check { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); visibility: hidden; }
.picker-item-meta + .picker-check { margin-left: 4px; }
.picker-item-label + .picker-check { margin-left: auto; }
.picker-option[aria-selected="true"] .picker-check { visibility: visible; }

.picker-empty { padding: 14px 12px; color: var(--ink-2); font-size: 14px; }

/* =========================================================
   Boyutlar: drawing + inputs
   ========================================================= */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 16px 20px 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.section-note {
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink-2);
}

/* "Tür" buttons (segmented control) */
.variants {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 20px 0;
}
.variants[hidden] { display: none; }

.variant-btn {
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  background: var(--white);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  cursor: pointer;
}
.variant-btn:hover { border-color: var(--ink-2); }
.variant-btn[aria-checked="true"] {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.variant-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Standard size picker sits above the inputs */
#size-box .picker { margin-bottom: 12px; }
#size-picker .picker-trigger { height: 42px; }
#size-picker .picker-panel { min-width: 260px; }
#size-picker .picker-trigger .picker-item-meta { display: none; }

/* Values that come from a standard table */
input[readonly] {
  background: var(--hover);
  color: var(--ink-2);
  border-style: dashed;
}
input[readonly]:focus { box-shadow: none; border-color: var(--line-dark); }

.dims {
  display: grid;
  grid-template-columns: 1fr 210px;
  gap: 20px;
  padding: 12px 20px 20px;
}

/* Drawing area with technical grid paper */
.drawing {
  margin: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background-color: #fbfaf7;
  background-image:
    linear-gradient(#ecebe5 1px, transparent 1px),
    linear-gradient(90deg, #ecebe5 1px, transparent 1px);
  background-size: 14px 14px;
  min-height: 320px;
}

.drawing-svg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.drawing-svg svg { width: 100%; max-width: 380px; height: auto; }

.drawing-caption {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.85);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
}
.drawing-caption span:first-child { color: var(--accent); }

/* Inputs column */
.fields-grid { display: contents; }

.field { margin-bottom: 12px; }
.field label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 4px;
}
.field label .sym { font-family: var(--mono); color: var(--accent); font-weight: 500; }

/* Input with a unit on the right (e.g. "mm") */
.input-unit { position: relative; display: block; }
.input-unit input { padding-right: 42px; }
.input-unit > span {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  pointer-events: none;
}

.btn-reset { width: 100%; margin-top: 4px; }

/* =========================================================
   Result panel
   ========================================================= */
.result { position: sticky; top: calc(var(--topbar-h) + 19px); }

.result-head {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
}

.result-main {
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.result-label {
  display: block;
  font-size: 12px;
  color: var(--ink-2);
  margin-bottom: 2px;
}

.result-big {
  font-size: 32px;
  font-weight: 500;
  color: var(--accent);
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.result-table th,
.result-table td {
  padding: 9px 20px;
  border-bottom: 1px solid var(--line);
}
.result-table th { text-align: left; font-weight: 400; color: var(--ink-2); white-space: nowrap; }
.result-table td small { display: block; font-size: 12px; color: var(--ink-2); }
.result-table td { text-align: right; }

.formula { padding: 14px 20px; }
.formula code { font-family: var(--mono); font-size: 13px; word-break: break-word; }

.error {
  margin: 0;
  padding: 10px 20px;
  font-size: 13px;
  color: var(--error);
  border-top: 1px solid var(--line);
}

.result-actions { padding: 14px 20px 18px; border-top: 1px solid var(--line); }
.result-actions .btn { width: 100%; }

/* Mobile bottom bar, hidden on desktop */
.mobile-bar { display: none; }

/* =========================================================
   Calculation list
   ========================================================= */
.list { margin-top: 20px; }

.list-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 8px 12px 8px 20px;
  border-bottom: 1px solid var(--line);
}

.list-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.list-tools {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.price-field {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-right: 6px;
  font-size: 13px;
  color: var(--ink-2);
}
.price-field .input-unit { width: 130px; }
.price-field input { height: 34px; padding-right: 48px; }

.table-scroll { overflow-x: auto; }

.list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  white-space: nowrap;
}
.list-table th,
.list-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}
.list-table th:first-child,
.list-table td:first-child { padding-left: 20px; color: var(--ink-2); }
.list-table thead th {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-2);
  background: var(--hover);
}
.list-table tbody tr:hover { background: var(--hover); }
.list-table .num { text-align: right; }
.list-table tfoot td {
  font-weight: 600;
  border-bottom: none;
  border-top: 2px solid var(--ink);
}
.list-table tfoot #list-total { color: var(--accent); }

.btn-remove {
  width: 30px;
  height: 30px;
  font-size: 18px;
  line-height: 1;
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  color: var(--ink-2);
  cursor: pointer;
}
.btn-remove:hover { border-color: var(--error); color: var(--error); }

/* =========================================================
   Toast & backdrop
   ========================================================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 50;
  transform: translate(-50%, 20px);
  padding: 10px 16px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.toast a { color: #ffb38f; margin-left: 4px; }

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(20, 22, 25, 0.45);
  animation: fade-in 0.2s;
}
.backdrop[hidden] { display: none; }

@keyframes fade-in { from { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(100%); } }

/* =========================================================
   Footer note
   ========================================================= */
.note {
  margin: 20px 0 40px;
  font-size: 13px;
  color: var(--ink-2);
}

.note a { color: var(--ink-2); }

/* =========================================================
   Özel Hesapla: drawing editor
   ========================================================= */
.grid-setting { display: flex; align-items: center; gap: 6px; }
.grid-setting select {
  height: 28px;
  font: inherit;
  font-size: 12px;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  background: var(--white);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 20px 10px;
}

.tool-group { display: flex; }
.tool-group .tool { border-radius: 0; margin-left: -1px; }
.tool-group .tool:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.tool-group .tool:last-child { border-radius: 0 var(--radius) var(--radius) 0; }

.tool {
  height: 34px;
  min-width: 34px;
  padding: 0 12px;
  font-size: 13px;
  background: var(--white);
  border: 1px solid var(--line-dark);
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
}
.tool:hover { background: var(--hover); }
.tool[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; position: relative; }
#hole-toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); }
.tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; position: relative; }

.editor-wrap { padding: 0 20px; }

.editor {
  display: block;
  width: 100%;
  height: 440px;
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  touch-action: none; /* we handle touch ourselves (drawing, dragging) */
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}

/* Editor SVG parts (classes set in editor.js) */
.editor .grid-minor { stroke: #efede7; stroke-width: 1; }
.editor .grid-major { stroke: #e0ded6; stroke-width: 1; }
.editor .axis { stroke: #e9b9a1; stroke-width: 1; }
.editor .grid-label { font: 11px var(--mono); fill: var(--ink-2); }
.editor .shape { fill: #e3e1da; }
.editor .outline { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.editor .outline.hole { stroke-dasharray: 5 3; }
.editor .outline.selected { stroke: var(--accent); stroke-width: 2; }
.editor .edge-label { font: 11px var(--mono); fill: var(--accent); paint-order: stroke; stroke: #fbfaf7; stroke-width: 3; }
.editor .draft { fill: none; stroke: var(--accent); stroke-width: 2; }
.editor .draft.preview { stroke-dasharray: 4 4; stroke-width: 1.5; }
.editor .draft-point { fill: var(--accent); }
.editor .close-target { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }
.editor .handle { fill: var(--white); stroke: var(--ink); stroke-width: 1.5; cursor: grab; }
.editor .handle.active { fill: var(--accent); stroke: var(--accent); }
.editor .add-handle circle { fill: var(--white); stroke: var(--accent); stroke-width: 1; cursor: copy; }
.editor .add-handle path { stroke: var(--accent); stroke-width: 1.5; pointer-events: none; }
.editor .cursor { fill: var(--accent); }
.editor .cursor-label { font: 11px var(--mono); fill: var(--ink-2); }

.editor-help {
  margin: 8px 20px 4px;
  font-size: 12px;
  color: var(--ink-2);
}

/* Coordinate table */
.points-panel { padding: 10px 20px 4px; }
.points-panel .hint { margin: 0 0 8px; }
.points-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.points-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  font-size: 13px;
}
.check { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.points-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.points-table th {
  padding: 6px 4px;
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  color: var(--ink-2);
  border-bottom: 1px solid var(--line);
}
.points-table td { padding: 4px; border-bottom: 1px solid var(--line); }
.points-table td:first-child { width: 32px; color: var(--ink-2); }
.points-table input { height: 32px; font-size: 13px; }
.points-table tr.active td { background: var(--accent-soft); }
.points-table .row-actions { width: 70px; white-space: nowrap; text-align: right; }
.points-table .btn-remove:disabled { opacity: 0.3; cursor: default; }
.points-table tbody { display: block; max-height: 260px; overflow-y: auto; }
.points-table thead,
.points-table tbody tr { display: table; width: 100%; table-layout: fixed; }
.points-table th:first-child { width: 32px; }
.points-table th:last-child { width: 70px; }

.custom-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--line);
  margin-top: 12px;
}

.warnings {
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: #fff8f0;
  font-size: 13px;
  color: #9a3412;
}
.warnings p { margin: 0 0 6px; }
.warnings p:last-child { margin: 0; }

/* =========================================================
   Site footer (all pages)
   ========================================================= */
.site-footer {
  margin-top: 40px;
  background: var(--ink);
  color: #9aa0a8;
  font-size: 14px;
}

/* ".site-footer" in front so the mobile ".wrap" padding doesn't override these */
.site-footer .footer-inner {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
  padding-top: 32px;
  padding-bottom: 24px;
}

.footer-brand p { margin: 8px 0 0; max-width: 260px; }

.footer-links { display: flex; gap: 48px; flex-wrap: wrap; }
.footer-links h3 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #fff;
}
.footer-links a { display: block; padding: 3px 0; color: #9aa0a8; text-decoration: none; }
.footer-links a:hover { color: #fff; }

.site-footer .footer-bottom {
  padding-top: 14px;
  padding-bottom: 20px;
  border-top: 1px solid #33373d;
  font-size: 12px;
}

/* =========================================================
   Content pages (formulas, densities, FAQ, about...)
   ========================================================= */
.content { max-width: 760px; }

.section-title { margin: 32px 0 0; font-size: 18px; font-weight: 600; }
.content-wide { max-width: none; }

/* Explanation text under the calculator on the home page */
.home-info { margin-top: 32px; }
@media print { .home-info { display: none; } }

.prose {
  padding: 24px 28px;
  font-size: 15px;
  line-height: 1.65;
}
.prose h2 { margin: 28px 0 8px; font-size: 18px; font-weight: 600; }
.prose h2:first-child { margin-top: 0; }
.prose p, .prose ul, .prose ol { margin: 0 0 12px; }
.prose li { margin-bottom: 4px; }
.prose a { color: var(--accent); }
.prose code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--hover);
  border: 1px solid var(--line);
  padding: 1px 5px;
  border-radius: var(--radius);
}

/* Step-by-step calculation example */
.calc-steps {
  margin: 12px 0 16px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.8;
  background: #fbfaf7;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre;
}

/* Formula cards */
.formula-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.formula-card { display: flex; flex-direction: column; }
.formula-card .drawing { min-height: 0; border: none; border-bottom: 1px solid var(--line); border-radius: 0; }
.formula-card .drawing-svg svg { max-width: 220px; }
.formula-card-body { padding: 14px 16px 16px; }
.formula-card h2 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.formula-card .formula-line { margin: 0 0 6px; font-size: 13px; }
.formula-card .formula-line span { display: block; font-size: 12px; color: var(--ink-2); }
.formula-card code { font-family: var(--mono); font-size: 13px; }
.formula-card dl {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 10px;
  margin: 10px 0 0;
  font-size: 13px;
}
.formula-card dt { font-family: var(--mono); color: var(--accent); font-weight: 500; }
.formula-card dd { margin: 0; color: var(--ink-2); }

/* Density table */
.table-tools { padding: 14px 20px; border-bottom: 1px solid var(--line); }
.table-tools input { max-width: 320px; font-family: var(--sans); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th,
.data-table td { padding: 9px 20px; border-bottom: 1px solid var(--line); text-align: left; }
.data-table thead th { font-size: 12px; font-weight: 500; color: var(--ink-2); background: var(--hover); }
.data-table .num { text-align: right; font-family: var(--mono); }
.data-table .group-row td {
  padding-top: 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
  background: var(--white);
}

/* FAQ */
.faq details { border-bottom: 1px solid var(--line); }
.faq details:last-child { border-bottom: none; }
.faq summary {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; font-family: var(--mono); color: var(--accent); font-size: 18px; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq summary:hover { background: var(--hover); }
.faq .answer { padding: 0 24px 16px; color: var(--ink-2); line-height: 1.65; }
.faq .answer p { margin: 0 0 8px; }

/* =========================================================
   Tablet: result goes under the form
   ========================================================= */
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .result { position: static; }
}

/* =========================================================
   Mobile: app-like layout
   ========================================================= */
@media (max-width: 640px) {
  :root { --topbar-h: 48px; }

  body { font-size: 16px; }
  .wrap { padding: 0 12px; }

  /* 16px inputs stop iPhone from zooming in on focus */
  input { height: 46px; font-size: 16px; }

  /* On phones the menu is in the footer, only the logo stays on top */
  .topnav { display: none; }

  .page-title { padding: 16px 4px 12px; }
  .page-title h1 { font-size: 20px; }
  .has-mobile-bar .page-title p { display: none; } /* calculator page only */

  .layout { gap: 12px; }

  .pickers { gap: 8px; padding: 14px; grid-template-columns: 1fr 1fr; }
  /* Density gets its own row: label left, input, reset button */
  .density-field { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; }
  .density-field label { margin: 0; font-size: 13px; }
  .density-row { flex: 1; flex-wrap: nowrap; }
  .density-field input { height: 44px; }
  .density-reset {
    position: static;
    height: 44px;
    padding: 0 10px;
    border: 1px solid var(--line-dark);
    border-radius: var(--radius);
    color: var(--ink-2);
  }
  .picker-trigger { height: 52px; padding: 0 10px; gap: 8px; }
  .picker-value { gap: 8px; }
  .picker-value .picker-item-meta { display: none; } /* not enough space */

  /* The picker panel becomes a bottom sheet */
  .picker-panel {
    position: fixed;
    z-index: 45;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    min-width: 0;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: 14px 14px 0 0;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.2);
    padding-bottom: env(safe-area-inset-bottom);
    animation: slide-up 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
  }
  .picker-panel[hidden] { display: none; }
  #material-picker .picker-panel { left: 0; min-width: 0; }
  /* Fixed height so the sheet doesn't jump while searching */
  .picker-panel:has(.picker-search) { height: 75vh; }
  #material-picker .picker-list { max-height: none; }

  .sheet-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 16px 10px;
  }
  .sheet-handle {
    position: absolute;
    top: 6px;
    left: 50%;
    width: 36px;
    height: 4px;
    margin-left: -18px;
    border-radius: 2px;
    background: var(--line-dark);
  }
  .sheet-title { font-size: 17px; font-weight: 600; }
  .picker-close {
    padding: 6px 0;
    background: none;
    border: none;
    color: var(--accent);
    font-size: 15px;
    cursor: pointer;
  }

  .picker-search {
    margin: 0 16px 8px;
    width: calc(100% - 32px);
    height: 42px;
    border: none;
    border-radius: 10px;
    background: #efeee9;
  }
  .picker-search:focus { background: #e9e8e2; }

  .picker-list { max-height: none; flex: 1; padding-bottom: 12px; }
  .picker-group { padding: 14px 16px 6px; }
  .picker-option { min-height: 52px; padding: 0 16px; font-size: 16px; border-bottom: 1px solid var(--line); }
  .picker-option svg:not(.picker-check) { width: 28px; height: 28px; }
  .picker-check { width: 20px; height: 20px; }

  /* Drawing on top, inputs in two columns below */
  .section-head { padding: 14px 14px 0; }

  /* Tür buttons scroll sideways instead of wrapping */
  .variants { flex-wrap: nowrap; overflow-x: auto; padding: 10px 14px 2px; scrollbar-width: none; }
  .variants::-webkit-scrollbar { display: none; }
  .variant-btn { flex-shrink: 0; height: 38px; font-size: 14px; }
  #size-box { grid-column: 1 / -1; }
  #size-picker .picker-trigger { height: 48px; }
  #size-picker .picker-panel { left: 0; min-width: 0; }
  .dims { padding: 10px 14px 16px; }
  .drawing { min-height: 0; }
  .drawing-svg { padding: 8px; }
  .drawing-svg svg { max-width: 300px; }

  /* .fields "dissolves" so the size picker can move above the drawing */
  .dims { grid-template-columns: 1fr 1fr; gap: 0 10px; }
  .fields { display: contents; }
  #size-box { order: -1; }
  .drawing { grid-column: 1 / -1; margin-bottom: 14px; }
  .field,
  .btn-reset { order: 1; }
  .field { margin-bottom: 10px; }
  .btn-reset { grid-column: 1 / -1; height: 40px; }

  /* Result: the big total and button move to the bottom bar */
  .result-main,
  .result-actions { display: none; }
  .result-head { padding: 10px 14px; }
  .result-table th,
  .result-table td { padding: 10px 14px; }
  .formula { padding: 12px 14px; }

  .mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 25;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--line);
  }
  .mobile-bar .result-label { margin: 0; }
  .mobile-total { display: block; font-size: 22px; font-weight: 500; color: var(--accent); line-height: 1.2; }
  .mobile-bar .btn { height: 46px; padding: 0 18px; }

  /* Space so the bottom bar doesn't cover the content */
  body.has-mobile-bar { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(86px + env(safe-area-inset-bottom)); }

  /* List: each row becomes a card */
  .list { margin-top: 12px; }
  .list-head { padding: 12px 14px; }
  .list-tools { width: 100%; }
  .price-field { width: 100%; margin: 0 0 4px; }
  .price-field .input-unit { flex: 1; width: auto; }
  .price-field input { height: 42px; }
  .list-tools .btn { flex: 1; height: 38px; padding: 0 8px; }

  .list-table,
  .list-table tbody,
  .list-table tfoot { display: block; white-space: normal; }
  .list-table thead { display: none; }
  .list-table tr {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 2px 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--line);
  }
  .list-table td { padding: 0; border: none; text-align: left; }
  .list-table td:first-child { padding: 0; }
  .list-table tbody tr:hover { background: none; }

  .list-table .cell-no { grid-column: 1; grid-row: 1; }
  .list-table .cell-title { grid-column: 2; grid-row: 1; font-weight: 600; }
  .list-table .cell-remove { grid-column: 3; grid-row: 1 / span 2; align-self: start; }
  .list-table td[data-label] {
    grid-column: 2;
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 14px;
  }
  .list-table td[data-label]::before {
    content: attr(data-label);
    font-family: var(--sans);
    color: var(--ink-2);
  }
  .list-table .cell-total { font-weight: 600; color: var(--accent); }

  /* Footer total row as a simple card */
  .list-table tfoot tr { grid-template-columns: 1fr auto; border-top: 2px solid var(--ink); border-bottom: none; }
  .list-table tfoot td { border: none; }
  .list-table tfoot td:empty,
  .list-table tfoot #list-qty { display: none; }
  .list-table tfoot td[colspan] { grid-column: 1; }
  .list-table tfoot #list-total { grid-column: 2; grid-row: 1; text-align: right; }
  .list-table tfoot #list-cost { grid-column: 2; grid-row: 2; text-align: right; font-weight: 500; }

  .note { padding: 0 4px; }

  /* Özel Hesapla on phones */
  .toolbar { flex-wrap: nowrap; overflow-x: auto; padding: 10px 14px 8px; scrollbar-width: none; }
  .toolbar::-webkit-scrollbar { display: none; }
  .tool { height: 40px; font-size: 14px; flex-shrink: 0; }
  .editor-wrap { padding: 0 14px; }
  .editor { height: 62vw; min-height: 260px; }
  .editor-help { margin: 8px 14px 4px; }
  .points-panel { padding: 10px 14px 4px; }
  .points-table input { height: 38px; font-size: 16px; }
  .custom-fields { padding: 14px; }

  .site-footer { margin-top: 24px; }
  .site-footer .footer-inner { flex-direction: column; gap: 24px; }
  .footer-links { gap: 28px; }
  .footer-links a { padding: 6px 0; }   /* bigger touch targets */

  .prose { padding: 18px 16px; }
  .formula-grid { grid-template-columns: 1fr; gap: 12px; }
  .data-table th,
  .data-table td { padding: 9px 14px; }
  .table-tools { padding: 12px 14px; }
  .table-tools input { max-width: none; }
  .faq summary { padding: 16px; }
  .faq .answer { padding: 0 16px 16px; }
}

/* =========================================================
   Print: only the page title and the list are printed
   ========================================================= */
@media print {
  body { background: #fff; font-size: 12px; }
  .topbar,
  .site-footer,
  .layout,
  .note,
  .list-tools,
  .btn-remove,
  .mobile-bar,
  .toast,
  .has-mobile-bar .page-title p { display: none; } /* calculator page only */
  .page-title { padding: 0 0 12px; }
  .panel { border: none; }
  .list { margin: 0; }
  .list-head { padding-left: 0; }
  .list-table th:first-child,
  .list-table td:first-child { padding-left: 0; }
}
