/* Neutral zinc greys + one accent: the yellow of the iPhone Photos edit screen.
   Radius rule: controls 8px, containers 12px. */
:root {
  --bg: #f4f4f5; --surface: #fcfcfd; --text: #18181b; --muted: #63636b; --line: #e1e1e5;
  --accent: #e8a200; --accent-strong: #cf9000; --on-accent: #18181b; --stage: #1c1c1f;
  --r-ctl: 8px; --r-box: 12px;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f0f11; --surface: #19191c; --text: #ededf0; --muted: #a1a1aa; --line: #2c2c31; --stage: #0b0b0d; }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--text); word-break: keep-all; -webkit-text-size-adjust: 100%;
  font: 16px/1.7 -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
}
/* Japanese has no spaces, so keep-all would stop lines from wrapping at all */
:lang(ja) body { word-break: normal; line-break: strict; font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, "Noto Sans JP", system-ui, sans-serif; }
:lang(en) body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif; }
a { color: inherit; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* header / footer */
.site-header { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); }
.site-header .wrap { display: flex; align-items: center; gap: 8px; height: 56px; }
.logo { font-weight: 800; font-size: 18px; text-decoration: none; white-space: nowrap; }
.site-header .logo { margin-right: auto; }
.dropdown { position: relative; padding: 0; border: 0; } /* not the FAQ details style */
.dropdown summary {
  display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--r-ctl);
  font-size: 14px; color: var(--text); cursor: pointer; list-style: none; user-select: none; white-space: nowrap;
}
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown summary:hover, .dropdown[open] summary { border-color: var(--muted); }
.dropdown svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dropdown .chev { width: 14px; height: 14px; color: var(--muted); transition: transform .15s; }
.dropdown[open] .chev { transform: rotate(180deg); }
.dropdown nav {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 20; min-width: 168px; padding: 6px;
  display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-box);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .16);
}
.dropdown:not([open]) nav { display: none; }
.dropdown nav a { padding: 10px 12px; border-radius: var(--r-ctl); font-size: 15px; text-decoration: none; white-space: nowrap; }
.dropdown nav a:hover { background: var(--bg); }
.dropdown nav a[aria-current] { font-weight: 700; color: var(--accent-strong); }
@media (max-width: 480px) { .dropdown.menu summary span, .dropdown.menu .chev { display: none; } }
.site-footer { border-top: 1px solid var(--line); margin-top: 64px; padding: 28px 0; font-size: 14px; color: var(--muted); }
.site-footer nav { display: flex; flex-wrap: wrap; gap: 16px; }

/* controls */
button, .btn {
  font: inherit; font-size: 14px; min-height: 38px; padding: 7px 12px; border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover:not(:disabled), .btn:hover { border-color: var(--muted); }
button:active:not(:disabled), .btn:active { transform: translateY(1px); }
button:disabled, fieldset:disabled button { opacity: .45; cursor: not-allowed; }
.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 700; }
.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=text], textarea, select {
  font: inherit; font-size: 16px; width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-ctl);
  background: var(--surface); color: var(--text);
}
textarea { resize: vertical; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--surface); }
input[type=range] { accent-color: var(--accent); }

/* editor */
.intro { padding: 28px 0 16px; }
.intro h1 { font-size: clamp(22px, 3.2vw, 32px); line-height: 1.3; margin: 0; }
.editor { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-box); overflow: hidden; touch-action: manipulation; } /* no double-tap zoom: double-tap resets a slider */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px; border-bottom: 1px solid var(--line); }
.toolbar .spacer { flex: 1; }
.zoom { display: flex; gap: 4px; }
.zoom #zoomFit { min-width: 64px; font-variant-numeric: tabular-nums; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.stage { position: relative; display: flex; overflow: auto; padding: 16px; background: var(--stage); height: min(72vh, 760px); min-height: 360px; }
.stage.dragover { outline: 3px dashed var(--accent); outline-offset: -8px; }
#view {
  display: none; flex: none; margin: auto; touch-action: none; box-shadow: 0 2px 24px rgba(0, 0, 0, .45);
  background: repeating-conic-gradient(#3a3a3e 0 25%, #2c2c30 0 50%) 0 0 / 16px 16px;
}
.has-photo #view { display: block; }
.has-photo .dropzone { display: none; }
.has-photo .stage { touch-action: none; } /* app.js handles touch pan and pinch zoom */
.stage[data-mode=draw] #view { cursor: crosshair; }
.stage[data-mode=text] #view { cursor: text; }
.stage[data-mode=crop] #view { cursor: move; }
.dropzone {
  margin: auto; width: 100%; max-width: 460px; padding: 48px 24px; border: 2px dashed #4a4a50; border-radius: var(--r-box);
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; color: #a8a8ae; font-size: 14px; cursor: pointer;
}
.dropzone:hover { border-color: var(--accent); }
.dropzone strong { font-size: 18px; color: #f4f4f5; }

.panel { display: flex; flex-direction: column; min-width: 0; margin: 0; padding: 0; border: 0; border-left: 1px solid var(--line); height: min(72vh, 760px); min-height: 360px; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; min-width: 0; padding: 12px 4px; border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; color: var(--muted); }
.tabs button[aria-selected=true] { color: var(--text); border-bottom-color: var(--accent); font-weight: 700; }
.tabpanel { flex: 1; overflow-y: auto; padding: 14px 16px 20px; }
.tabpanel h3 { margin: 18px 0 6px; font-size: 12px; font-weight: 700; color: var(--muted); }
.tabpanel h3:first-child { margin-top: 0; }
.slider { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 8px; margin: 2px 0 6px; }
.slider label { font-size: 14px; }
.slider output { min-width: 3ch; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.slider input[type=range] { grid-column: 1 / -1; width: 100%; margin: 2px 0; }
.slider .adj-input {
  width: 52px; height: 26px; padding: 0 8px; text-align: right; font: inherit; font-size: 13px; font-variant-numeric: tabular-nums;
  border: 1px solid transparent; border-radius: 6px; background: var(--bg); color: var(--text); -moz-appearance: textfield; appearance: textfield;
}
.slider .adj-input::-webkit-inner-spin-button, .slider .adj-input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.slider .adj-input:hover:not(:disabled) { border-color: var(--line); }
.slider .adj-input:focus { border-color: var(--accent); outline: none; }
.slider .adj-input:disabled { color: var(--muted); }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.btn-row.end { justify-content: flex-end; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { min-height: 34px; padding: 4px 10px; }
.chips button[aria-pressed=true] { background: var(--text); border-color: var(--text); color: var(--surface); }
.field { display: flex; flex-direction: column; gap: 4px; margin: 8px 0; font-size: 14px; }
.field.inline { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px; }
.check { display: inline-flex; align-items: center; gap: 4px; }
.inline-form { display: flex; gap: 6px; }
.hint { margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.label-row { position: relative; display: flex; align-items: center; gap: 6px; }
.info {
  display: inline-flex; align-items: center; justify-content: center; flex: none; width: 18px; height: 18px; border: 1.5px solid var(--muted); border-radius: 50%;
  color: var(--muted); font: italic 700 11px/1 Georgia, serif; cursor: help; user-select: none;
}
.info-tip {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5; display: none; padding: 10px 12px; border-radius: var(--r-ctl);
  background: var(--text); color: var(--bg); font-size: 13px; line-height: 1.55; box-shadow: 0 6px 20px rgba(0, 0, 0, .2);
}
.info:hover + .info-tip, .info:focus-visible + .info-tip, .info[aria-expanded=true] + .info-tip { display: block; }
.presets { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.presets li { display: flex; gap: 6px; }
.presets .apply { flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; white-space: normal; padding: 8px 12px; }
.presets .apply small { font-size: 12px; color: var(--muted); }
.presets .empty { font-size: 14px; color: var(--muted); }

.toolbar svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stage-wrap { position: relative; min-width: 0; min-height: 0; display: flex; }
.stage-wrap .stage { flex: 1; min-width: 0; }
.compare {
  position: absolute; right: 12px; bottom: 12px; z-index: 2; display: none; min-height: 36px; padding: 6px 12px;
  border-color: transparent; border-radius: 999px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 13px;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: none;
}
.compare:hover:not(:disabled) { border-color: transparent; }
.compare.on { background: var(--accent); color: var(--on-accent); }
.has-photo .compare { display: inline-flex; }

/* phones and small tablets: the editor fills the screen so the photo stays in view while you adjust */
@media (max-width: 860px) {
  .intro { padding: 18px 0 12px; }
  .editor {
    display: flex; flex-direction: column; margin: 0 -16px; border-radius: 0; border-left: 0; border-right: 0;
    height: calc(100vh - 57px); height: calc(100dvh - 57px); min-height: 480px; scroll-margin-top: 57px;
  }
  .toolbar { flex-wrap: nowrap; gap: 6px; padding: 8px; }
  .workspace { flex: 1; min-height: 0; grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .stage { height: auto; min-height: 0; padding: 8px; }
  .panel { height: auto; min-height: 0; border-left: 0; border-top: 1px solid var(--line); }
  .tabs { order: 2; border-bottom: 0; border-top: 1px solid var(--line); }
  .tabs button { border-bottom: 0; border-top: 2px solid transparent; padding: 10px 2px; min-height: 46px; }
  .tabs button[aria-selected=true] { border-top-color: var(--accent); }
  .tabpanel { flex: none; height: clamp(150px, 30dvh, 280px); padding: 12px 16px; }
  #toast { bottom: 84px; }
}
@media (max-width: 640px) {
  .toolbar .lbl, #zoomIn, #zoomOut { display: none; }
  .toolbar button, .toolbar .btn { padding: 7px 10px; }
  .zoom #zoomFit { min-width: 56px; }
}
/* touch screens: bigger targets, and no iOS auto-zoom when a number box gets focus */
@media (pointer: coarse) {
  button, .btn { min-height: 44px; }
  .chips button { min-height: 40px; }
  input[type=range] { height: 32px; }
  .slider .adj-input { font-size: 16px; width: 60px; height: 32px; }
  input[type=color] { width: 52px; height: 44px; }
  .check input { width: 20px; height: 20px; }
  .info { width: 24px; height: 24px; font-size: 13px; }
}

/* ads: reserve space only once an ad is inserted (empty slots collapse) */
.ad-slot { margin: 40px auto; min-height: 100px; text-align: center; }
.ad-slot:empty { display: none; }

/* article */
.content { max-width: 820px; margin: 0 auto; padding: 0 0 16px; }
.content section { margin: 64px 0; }
.content h2 { margin: 0 0 12px; font-size: clamp(22px, 2.6vw, 28px); line-height: 1.35; }
.content h3 { margin: 28px 0 8px; font-size: 18px; }
.steps { margin: 0; padding-left: 1.4em; }
.steps li { margin: 0 0 10px; padding-left: 4px; }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 0; font-size: 15px; }
.keys dt { color: var(--muted); }
.keys dd { margin: 0; }
kbd { font: 13px/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: 3px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--surface); }
.glossary { display: grid; grid-template-columns: 7.5rem 1fr; gap: 14px 24px; margin: 0; }
.glossary dt { font-weight: 700; }
.glossary dd { margin: 0; }
.recipes { list-style: none; margin: 8px 0 0; padding: 0; }
.recipes > li { display: grid; grid-template-columns: 1fr auto; column-gap: 24px; align-items: center; padding: 20px 0; }
.recipes > li + li { border-top: 1px solid var(--line); }
.recipes h3 { margin: 0 0 2px; }
.recipes button { grid-column: 2; grid-row: 1 / span 2; }
.vals { grid-column: 1; list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.vals li { padding: 2px 8px; border-radius: var(--r-ctl); background: var(--bg); border: 1px solid var(--line); font-size: 13px; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) {
  .glossary { grid-template-columns: 1fr; gap: 2px; }
  .glossary dd { margin-bottom: 14px; }
  .recipes > li { grid-template-columns: 1fr; }
  .recipes button { grid-column: 1; grid-row: auto; justify-self: start; margin-top: 12px; }
}
details { padding: 14px 0; border-bottom: 1px solid var(--line); }
/* guide, glossary and FAQ fold away under the recipes */
.content [id] { scroll-margin-top: 64px; }
.fold { padding: 0; border-bottom: 0; border-top: 1px solid var(--line); }
.fold:last-of-type { border-bottom: 1px solid var(--line); }
.fold[open] { padding-bottom: 32px; }
.fold > summary { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 20px 0; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary h2 { margin: 0; font-size: clamp(18px, 2.2vw, 22px); }
.fold > summary::after {
  content: ''; flex: none; width: 9px; height: 9px; margin-right: 4px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-3px) rotate(45deg); transition: transform .15s;
}
.fold[open] > summary::after { transform: translateY(2px) rotate(-135deg); }
summary { font-weight: 700; cursor: pointer; }
details p { margin: 8px 0 0; }

/* plain text pages */
.page { max-width: 760px; margin: 0 auto; padding: 32px 16px; }
.page h1 { font-size: clamp(24px, 3vw, 32px); line-height: 1.3; margin: 0 0 8px; }
.page h2 { font-size: 20px; margin: 36px 0 8px; }
.page .muted { color: var(--muted); }

dialog { width: min(420px, calc(100vw - 32px)); padding: 20px; border: 1px solid var(--line); border-radius: var(--r-box); background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(0, 0, 0, .5); }
dialog h2 { margin: 0 0 12px; font-size: 20px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 100; max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: var(--r-ctl);
  background: var(--text); color: var(--bg); font-size: 14px; opacity: 0; pointer-events: none; transform: translate(-50%, 16px); transition: .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
