:root {
  --ink: #142424;
  --muted: #4d5f5f;
  --brand: #0f3d3e;
  --accent: #f4b860;
  --ok: #1d7a4c;
  --bad: #b3261e;
  --line: #d9e1df;
  --paper: #f6f8f7;
  --card: #fff;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Devanagari", "Noto Sans Gujarati", sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--brand); text-underline-offset: 2px; }
a:hover { color: #0a2a2b; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .75rem 1rem; background: var(--brand); color: #fff;
}
.top a { color: #fff; text-decoration: none; }
.brand { font-weight: 700; font-size: 1.1rem; }
.top nav { display: flex; gap: 1rem; font-size: .95rem; }
.top nav a:hover { text-decoration: underline; }

main { max-width: 760px; margin: 0 auto; padding: 0 1rem 2rem; }
.hero { padding: 1.5rem 0 .5rem; }
.hero h1 { font-size: clamp(1.45rem, 4.5vw, 2.1rem); line-height: 1.2; margin: 0 0 .5rem; }
.lead { color: var(--muted); margin: 0; font-size: 1.05rem; }

.tool {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; margin: 1rem 0 2rem; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.step { margin-bottom: 1.25rem; }
.step-label { display: flex; align-items: center; gap: .5rem; font-weight: 650; margin-bottom: .5rem; }
.num {
  display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: .85rem; flex: none;
}
select, input[type="number"] {
  width: 100%; font: inherit; padding: .6rem .7rem; border: 1px solid #b9c6c3; border-radius: 8px; background: #fff; color: var(--ink);
}
.spec { font-size: .9rem; color: var(--muted); margin: .4rem 0 0; }
.spec:empty { display: none; }

.drop {
  display: block; border: 2px dashed #9fb3af; border-radius: var(--radius); padding: 1.2rem; text-align: center;
  cursor: pointer; background: #fbfcfc;
}
.drop.over, .drop:hover { border-color: var(--brand); background: #eef4f3; }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop:focus-within { outline: 3px solid var(--accent); outline-offset: 2px; }

.viewport {
  position: relative; width: min(100%, 340px); aspect-ratio: 3.5 / 4.5; margin: 0 auto;
  border-radius: 8px; overflow: hidden; background: repeating-conic-gradient(#eef1f0 0 25%, #fff 0 50%) 0 0 / 20px 20px;
  touch-action: none; cursor: grab; box-shadow: 0 0 0 2px var(--brand);
}
.viewport:active { cursor: grabbing; }
.viewport canvas { width: 100%; height: 100%; display: block; }
.hint { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: .95rem; pointer-events: none; }
.tool.has-image .hint { display: none; }
.tool:not(.has-image) .viewport canvas { visibility: hidden; }
.controls { display: flex; align-items: center; gap: 1rem; justify-content: center; margin: .75rem 0; flex-wrap: wrap; }
.zoom { display: flex; align-items: center; gap: .5rem; }
input[type="range"] { accent-color: var(--brand); width: 160px; }

button, .button {
  font: inherit; font-weight: 650; border: 0; border-radius: 8px; padding: .65rem 1.1rem; cursor: pointer;
  background: var(--brand); color: #fff; text-decoration: none; display: inline-block;
}
.button:hover { background: #0a2a2b; color: #fff; }
button.secondary { background: #e4ecea; color: var(--ink); }
button.secondary:hover { background: #d4e0dd; }

.adjust { border-top: 1px solid var(--line); padding-top: .75rem; }
.adjust summary { cursor: pointer; font-weight: 600; color: var(--brand); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem; margin: .75rem 0; }
.grid label { font-size: .9rem; color: var(--muted); display: grid; gap: .25rem; }
.check { display: flex; align-items: center; gap: .5rem; font-size: .95rem; margin-top: .25rem; }

.error { background: #fdecea; color: var(--bad); border-radius: 8px; padding: .75rem 1rem; }
.result { border-top: 1px solid var(--line); padding-top: 1rem; }
.result-row { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
#out { max-width: 160px; height: auto; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.size { font-weight: 700; font-size: 1.1rem; margin: 0 0 .4rem; }
.checks { list-style: none; padding: 0; margin: 0 0 .9rem; font-size: .92rem; }
.checks li::before { content: "✓ "; color: var(--ok); font-weight: 700; }

.content h2 { font-size: 1.25rem; margin: 1.75rem 0 .5rem; }
.content li { margin-bottom: .35rem; }
.content details { border-bottom: 1px solid var(--line); padding: .6rem 0; }
.content summary { cursor: pointer; font-weight: 600; }
.inline { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .5rem 1rem; }
.cards { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.cards a { display: grid; gap: .2rem; padding: .9rem 1rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.cards a:hover { border-color: var(--brand); }
.cards span { color: var(--muted); font-size: .9rem; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; background: var(--card); }
th, td { border: 1px solid var(--line); padding: .5rem .6rem; text-align: left; vertical-align: top; }
th { background: #eef4f3; }
.source { font-size: .9rem; color: var(--muted); }
.prose { padding-top: 1rem; }
.prose h1 { font-size: 1.6rem; }

.foot { background: #e9efed; color: var(--muted); font-size: .9rem; padding: 1.5rem 1rem; }
.foot > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.foot .notice { color: var(--ink); }
.small { font-size: .82rem; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
