:root {
  color-scheme: light;
  --ink: #173536;
  --muted: #5d6b6a;
  --teal: #087d70;
  --paper: #f5f5ee;
  --line: #dce4de;
  --gold: #d9a441;
  --soft: #eaf4ec;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
summary {
  -webkit-tap-highlight-color: transparent;
}
button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 12px 16px;
  min-height: 46px;
  cursor: pointer;
  font-weight: 600;
  touch-action: manipulation;
}
button:hover {
  border-color: var(--teal);
  background: #f0f7f1;
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}
.primary:hover {
  background: #24504e;
  color: #fff;
}
.danger {
  border-color: #d49183;
  color: #a23d2b;
}
.text-button {
  border: 0;
  background: none;
  padding-left: 0;
  font-size: 0.86rem;
  text-align: left;
}
.masthead {
  max-width: 1220px;
  margin: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: max(28px, calc(env(safe-area-inset-top) + 16px)) 32px 4px;
}
.brand {
  display: flex;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.25rem;
  font-weight: 750;
  align-items: center;
  letter-spacing: -0.6px;
}
.brand small {
  display: block;
  font-size: 0.57rem;
  letter-spacing: 2.3px;
  color: var(--muted);
  margin-top: 4px;
}
.privacy-pill {
  font-size: 0.73rem;
  font-weight: 650;
  padding: 9px 12px;
  border-radius: 99px;
  background: #e3ecdf;
}
.privacy-pill:before {
  content: "●";
  color: var(--teal);
  margin-right: 7px;
  font-size: 0.65rem;
}
main {
  max-width: 1220px;
  margin: auto;
  padding: 0 32px;
}
.intro {
  padding: 48px 0 35px;
}
.eyebrow {
  font-size: 0.66rem;
  font-weight: 750;
  letter-spacing: 2.3px;
  color: var(--teal);
}
h1 {
  font-size: clamp(2.8rem, 5.4vw, 4.6rem);
  font-weight: 650;
  letter-spacing: -3.2px;
  line-height: 1.04;
  margin: 18px 0;
}
h1 em {
  font-weight: 550;
  color: var(--teal);
  font-family: Georgia, serif;
}
.intro > p:last-child {
  color: var(--muted);
  line-height: 1.65;
  font-size: 0.98rem;
}
.workspace {
  display: grid;
  grid-template-columns: minmax(270px, 340px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}
/* A large SVG must scroll INSIDE its card, never widen the mobile viewport.
   The default grid-item min-width:auto otherwise propagates its 850px width. */
.card {
  min-width: 0;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 24px;
  box-shadow: 0 8px 28px #17353605;
}
.section-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}
.section-heading h2 {
  font-size: 1.12rem;
  letter-spacing: -0.4px;
  margin: 0;
}
.section-heading > div {
  flex: 1;
  min-width: 0;
}
.section-heading p {
  margin: 6px 0 0;
}
.step {
  font-size: 0.7rem;
  color: var(--teal);
  font-weight: 750;
  background: var(--soft);
  padding: 8px;
  border-radius: 50%;
}
.compact {
  padding: 8px 11px;
  font-size: 0.8rem;
}
.capture-actions {
  display: grid;
  gap: 10px;
}
.capture-actions .primary {
  min-height: 58px;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
}
.field {
  display: grid;
  gap: 7px;
  margin: 19px 0 8px;
  font-size: 0.82rem;
  font-weight: 600;
}
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcf9;
  color: var(--ink);
  padding: 11px;
  min-height: 46px;
  width: 100%;
  min-width: 0;
}
select {
  padding-right: 22px;
}
textarea {
  font-family: ui-monospace, monospace;
  font-size: 0.77rem;
  line-height: 1.5;
  resize: vertical;
}
.muted {
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.55;
}
.inline-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}
.inline-buttons > button {
  flex: 1;
  font-size: 0.8rem;
  min-width: 90px;
}
details {
  border-top: 1px solid var(--line);
  margin-top: 20px;
  padding-top: 17px;
}
summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  min-height: 32px;
}
.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 12px 0;
}
.fields label {
  font-size: 0.78rem;
  font-weight: 600;
  display: grid;
  gap: 6px;
}
.check {
  display: flex;
  gap: 10px;
  font-size: 0.8rem;
  align-items: center;
  line-height: 1.4;
  margin: 16px 0;
}
.check input {
  width: 19px;
  height: 19px;
  min-height: 19px;
  accent-color: var(--teal);
  flex-shrink: 0;
}
.status {
  border-radius: 12px;
  background: #f2f6ef;
  padding: 14px 16px;
  display: grid;
  gap: 6px;
  margin-bottom: 18px;
  overflow-wrap: anywhere;
}
.status strong {
  font-size: 0.89rem;
}
.status span {
  font-size: 0.77rem;
  color: var(--muted);
  line-height: 1.5;
}
.status.error {
  background: #fff0eb;
}
.status.warning {
  background: #fff8e9;
}
progress {
  width: 100%;
  height: 9px;
  accent-color: var(--teal);
}
[hidden] {
  display: none !important;
}
.board-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: end;
  margin: 14px 0;
}
.board-toolbar label {
  display: grid;
  gap: 4px;
  font-size: 0.7rem;
  color: var(--muted);
}
.board-toolbar select {
  font-size: 0.78rem;
  max-width: 150px;
  min-height: 42px;
  padding: 8px;
}
.view-tabs {
  display: flex;
  gap: 3px;
}
.view-tabs button {
  min-height: 42px;
  font-size: 0.76rem;
  padding: 8px 11px;
}
.view-tabs [aria-pressed="true"] {
  background: var(--soft);
  border-color: #bdcfc2;
}
.board-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: auto;
  border-radius: 9px;
  border: 1px solid #b8c9bf;
  background: white;
}
#board {
  width: 100%;
  display: block;
  min-width: 240px;
  max-height: 760px;
}
.cell-hit {
  fill: #fff;
  stroke: #becdc5;
  stroke-width: 1;
}
.board-cell {
  cursor: pointer;
  outline: none;
}
.board-cell:focus .cell-hit {
  stroke: var(--teal);
  stroke-width: 4;
}
.board-cell text {
  pointer-events: none;
  fill: var(--ink);
  font-size: 30px;
  text-anchor: middle;
  font-weight: 630;
}
.board-cell.answer text {
  fill: var(--teal);
  font-weight: 500;
}
.board-cell.uncertain .cell-hit {
  fill: #fff0cc;
}
.board-cell.conflict .cell-hit {
  fill: #ffdcd1;
}
.board-cell.selected .cell-hit {
  fill: #bde2d5;
  stroke: var(--teal);
  stroke-width: 3;
}
.board-cell.blocked .cell-hit {
  fill: #173536;
}
.board-cell.blocked > text {
  fill: white;
}
.board-cell .kakuro-clue {
  font-size: 19px;
  fill: white;
}
.board-cell .cage-label {
  font-size: 14px;
  fill: #687b73;
  font-weight: 600;
  text-anchor: start;
}
.box-line {
  stroke: var(--ink);
  stroke-width: 3;
  pointer-events: none;
  fill: none;
}
.cage-line {
  stroke: #55776d;
  stroke-width: 1.5;
  fill: none;
  pointer-events: none;
}
.inequality {
  fill: var(--ink);
  font-size: 22px;
  text-anchor: middle;
  pointer-events: none;
}
.loop-edge {
  stroke: var(--teal);
  stroke-width: 6;
  stroke-linecap: round;
  pointer-events: none;
}
.legend {
  display: flex;
  gap: 13px;
  flex-wrap: wrap;
  font-size: 0.65rem;
  color: var(--muted);
  margin: 14px 0;
}
.legend span {
  display: flex;
  align-items: center;
  gap: 5px;
}
.legend i {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
.given-dot {
  background: var(--ink);
}
.answer-dot {
  background: var(--teal);
}
.review-dot {
  background: var(--gold);
}
.solve-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.solve-actions .primary {
  flex: 1;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  min-width: 160px;
}
.solve-actions > button {
  font-size: 0.86rem;
}
.small-note {
  font-size: 0.71rem;
  color: var(--muted);
  line-height: 1.5;
}
.review-note {
  padding: 12px;
  border-left: 3px solid var(--gold);
  font-size: 0.79rem;
  line-height: 1.6;
  background: #fff9eb;
  white-space: pre-line;
}
.subeditor {
  background: #f4f8f1;
  padding: 12px;
  border-radius: 12px;
  margin-bottom: 14px;
}
.subeditor p {
  font-size: 0.8rem;
  margin: 0;
  line-height: 1.5;
}
.viewfinder {
  position: relative;
  background: var(--ink);
  border-radius: 12px;
  overflow: hidden;
}
.viewfinder video {
  display: block;
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
}
.camera-guide {
  position: absolute;
  inset: 12%;
  border: 2px dashed #ffffffb8;
  border-radius: 10px;
  pointer-events: none;
}
#crop-canvas,
#solution-photo {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 10px;
}
#crop-canvas {
  touch-action: none;
  max-height: 75vh;
  object-fit: contain;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 20px;
  max-width: 420px;
  width: calc(100% - 32px);
  padding: 24px;
  color: var(--ink);
  box-shadow: 0 20px 100px #0003;
}
dialog::backdrop {
  background: #132c3377;
  backdrop-filter: blur(3px);
}
dialog h2 {
  font-size: 1.2rem;
}
dialog p {
  font-size: 0.86rem;
  line-height: 1.55;
}
dialog .section-heading {
  justify-content: space-between;
}
#clue-crop {
  display: block;
  width: 140px;
  height: 140px;
  border-radius: 12px;
  margin: 12px auto;
  border: 1px solid var(--line);
  image-rendering: auto;
}
.error-text {
  color: #a23d2b;
}
footer {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 32px 0 28px;
  color: var(--muted);
  font-size: 0.68rem;
}
footer a {
  color: var(--ink);
  text-underline-offset: 3px;
}
button:focus-visible,
select:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid #74b5a6;
  outline-offset: 3px;
}
@media (max-width: 760px) {
  .masthead {
    padding: max(20px, calc(env(safe-area-inset-top) + 10px)) 18px 0;
  }
  main {
    padding: 0 14px;
  }
  .intro {
    padding: 26px 4px 18px;
  }
  h1 {
    font-size: 3rem;
    letter-spacing: -2px;
  }
  .intro br:not(.desktop) {
    display: none;
  }
  .intro .desktop {
    display: none;
  }
  .intro > p:last-child {
    font-size: 0.85rem;
  }
  .eyebrow {
    font-size: 0.6rem;
  }
  .workspace {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
  .card {
    padding: 18px;
    border-radius: 18px;
  }
  .capture-actions {
    grid-template-columns: 1.3fr 1fr;
  }
  .capture-actions .primary {
    min-height: 52px;
    font-size: 0.82rem;
  }
  .capture-actions > button {
    padding: 10px 8px;
    font-size: 0.82rem;
  }
  .section-heading {
    margin-bottom: 14px;
  }
  .capture > .field {
    margin-top: 15px;
  }
  .capture > details {
    margin-top: 14px;
    padding-top: 12px;
  }
  .privacy-pill {
    font-size: 0.65rem;
  }
  .solve-actions {
    position: sticky;
    bottom: 0;
    padding: 10px 0 max(10px, env(safe-area-inset-bottom));
    background: #ffffffed;
    backdrop-filter: blur(8px);
    z-index: 2;
  }
  .board-toolbar {
    gap: 5px;
  }
  .legend {
    gap: 10px;
  }
  .brand {
    font-size: 1.1rem;
  }
  .brand img {
    width: 32px;
    height: 32px;
  }
  .intro h1 br {
    display: none;
  }
  footer {
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
}
@media (prefers-reduced-motion: no-preference) {
  button {
    transition:
      background 0.12s,
      border-color 0.12s;
  }
}
@media print {
  header,
  .capture,
  .intro,
  .solve-actions,
  .board-toolbar,
  details,
  .status,
  footer,
  .legend,
  .small-note {
    display: none !important;
  }
  .workspace {
    display: block;
  }
  .card {
    border: 0;
    box-shadow: none;
  }
  main {
    padding: 0;
  }
  #board {
    max-height: none;
  }
}
