:root {
  --paper: #f4f7fa;
  --card: #ffffff;
  --ink: #10203a;
  --ink-2: #4a5b74;
  --line: #d5dee8;
  --ruler: #ffcb2e;
  --ruler-deep: #dca90f;
  --blue: #2447f9;
  --blue-ink: #1633c4;
  --radius: 12px;
  --font: 'Onest Variable', Onest, system-ui, -apple-system, 'Segoe UI', 'Hiragino Sans', 'Yu Gothic UI', 'Noto Sans JP', sans-serif;
  --display: 'Unbounded Variable', 'Onest Variable', system-ui, 'Hiragino Sans', 'Yu Gothic UI', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.6 var(--font); font-feature-settings: 'tnum' 1; }
img, svg { max-width: 100%; }
a { color: var(--blue-ink); text-underline-offset: 3px; }
a:hover { color: var(--blue); }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }
.wrap { width: min(1280px, 100% - 32px); margin-inline: auto; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 50; }
.skip:focus { left: 8px; }

/* header */
.site-head { background: var(--card); border-bottom: 1px solid var(--line); }
.head-row { display: flex; align-items: center; gap: 18px; padding: 12px 0; }
.brand { display: flex; align-items: center; gap: 10px; font: 700 1.05rem/1 var(--display); color: var(--ink); text-decoration: none; letter-spacing: -.01em; white-space: nowrap; }
.brand-mark { width: 14px; height: 34px; background: var(--ruler); border-radius: 2px; position: relative; box-shadow: inset -3px 0 0 var(--ruler-deep); }
.brand-mark::before { content: ''; position: absolute; right: 3px; top: 4px; bottom: 4px; width: 7px; background: repeating-linear-gradient(to bottom, #1b1b1b 0 1.5px, transparent 1.5px 6px); }
.nav { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; flex: 1; padding: 2px; }
.nav::-webkit-scrollbar { display: none; }
.nav a { padding: 7px 12px; border-radius: 999px; text-decoration: none; color: var(--ink-2); font-weight: 550; font-size: .92rem; white-space: nowrap; }
.nav a:hover { background: var(--paper); color: var(--ink); }
.nav a[aria-current='page'] { background: var(--ink); color: #fff; }
.lang { position: relative; }
.lang select { appearance: none; font: inherit; font-size: .9rem; font-weight: 550; padding: 7px 30px 7px 12px; border: 1px solid var(--line); border-radius: 999px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%2310203a' stroke-width='2'%3E%3Cpath d='m1 1 5 5 5-5'/%3E%3C/svg%3E") no-repeat right 11px center; color: var(--ink); cursor: pointer; }

/* hero */
.hero { padding: 34px 0 18px; }
.hero h1 { font: 700 clamp(1.7rem, 3.6vw + .4rem, 2.9rem)/1.12 var(--display); letter-spacing: -.025em; margin: 0 0 10px; max-width: 22ch; }
.hero p { margin: 0; color: var(--ink-2); font-size: 1.08rem; max-width: 62ch; }
[lang='ja'] .hero h1, [lang='ja'] h2 { letter-spacing: 0; line-height: 1.3; }

/* studio */
.studio { display: grid; grid-template-columns: minmax(0, 1fr) 372px; gap: 20px; align-items: start; margin-bottom: 34px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.stage-col { min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line); }
.toolbar .sp { flex: 1; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--paper); }
.seg button { border: 0; background: transparent; font: inherit; font-size: .88rem; font-weight: 600; padding: 5px 12px; border-radius: 999px; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed='true'] { background: var(--ink); color: #fff; }
.tbtn { font: inherit; font-size: .88rem; font-weight: 600; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); cursor: pointer; }
.tbtn:hover { border-color: var(--ink-2); }
.tbtn[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: #fff; }
.tbtn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.tbtn.primary:hover { background: var(--blue-ink); }
.zoom { display: inline-flex; align-items: center; gap: 6px; font-size: .85rem; color: var(--ink-2); }
.zoom input { width: 96px; accent-color: var(--blue); }
.stage { position: relative; }
#stage-scroll { overflow: auto; max-height: min(78vh, 780px); overscroll-behavior: contain; }
#canvas { min-height: 200px; }
#canvas svg { user-select: none; -webkit-user-select: none; touch-action: pan-y; }
.fig { touch-action: none; }
.empty { padding: 90px 24px; text-align: center; font-weight: 550; }
#stage3d { height: min(72vh, 640px); min-height: 380px; position: relative; }
.hint3d { position: absolute; left: 12px; bottom: 10px; font-size: .8rem; color: var(--ink-2); background: rgba(255,255,255,.85); padding: 4px 10px; border-radius: 999px; pointer-events: none; }
.studio[data-theme='night'] .hint3d { background: rgba(14,26,51,.85); color: #c9d6f5; }
.studio[data-view='3d'] #stage-scroll, .studio[data-view='3d'] .zoom, .studio[data-view='3d'] #tg-grid, .studio[data-view='3d'] #btn-svg { display: none; }
.studio[data-view='2d'] #stage3d { display: none; }
.couple { padding: 14px 18px; border-top: 1px solid var(--line); }
.couple-main { font-weight: 650; margin: 0 0 6px; font-size: 1.05rem; }
.couple-facts { margin: 0; padding-left: 1.1em; color: var(--ink-2); font-size: .94rem; }

.htable-wrap { border-top: 1px solid var(--line); padding: 4px 18px 14px; overflow-x: auto; }
.htable-wrap h2 { font: 650 1rem/1.3 var(--font); margin: 14px 0 8px; }
table { border-collapse: collapse; width: 100%; font-size: .93rem; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { color: var(--ink-2); font-weight: 600; font-size: .85rem; }
tbody th { font-weight: 600; }

/* side */
.side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; min-width: 0; }
.block { padding: 14px; }
.block h2 { font: 650 .98rem/1.3 var(--font); margin: 0 0 10px; }
.smart label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 6px; }
.smart .line { display: flex; gap: 6px; }
input[type='text'], input[type='search'], input[type='number'], select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); outline: 2px solid rgba(36,71,249,.25); }
.smart input { flex: 1; }
.smart .hint { margin: 6px 0 0; font-size: .82rem; color: var(--ink-2); }
.smart .actions { display: flex; gap: 6px; margin-top: 8px; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 420px; overflow: auto; }
.row { display: grid; grid-template-columns: 30px minmax(0, 1fr); gap: 8px; align-items: start; padding: 8px; border: 1px solid var(--line); border-radius: 10px; }
.nameline { display: flex; align-items: center; gap: 2px; }
.row .c-col { width: 30px; height: 30px; padding: 0; border: 0; background: none; cursor: pointer; margin-top: 2px; }
.row .fields { display: grid; gap: 5px; min-width: 0; }
.row .c-name { padding: 5px 8px; font-weight: 600; flex: 1; min-width: 0; }
.hgt { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.hgt input[type='number'] { width: 62px; padding: 5px 6px; }
.hgt .c-extra { width: 54px; }
.hgt .c-kind { padding: 5px 6px; max-width: 92px; }
.hgt span { color: var(--ink-2); font-size: .85rem; }
.ctrls { display: flex; gap: 2px; }
.ctrls button { width: 30px; height: 30px; border: 0; background: transparent; border-radius: 8px; color: var(--ink-2); cursor: pointer; display: grid; place-items: center; }
.ctrls button:hover { background: var(--paper); color: var(--ink); }
.ctrls .c-ref[aria-pressed='true'] { background: var(--ruler); color: #1b1b1b; }
.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.lib-search { width: 100%; margin-bottom: 8px; }
.cats { display: flex; gap: 4px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
.cats button { border: 1px solid var(--line); background: var(--card); font: inherit; font-size: .84rem; font-weight: 550; padding: 4px 11px; border-radius: 999px; cursor: pointer; white-space: nowrap; color: var(--ink-2); }
.cats button[aria-selected='true'] { background: var(--ruler); border-color: var(--ruler-deep); color: #1b1b1b; }
.lib { list-style: none; margin: 4px 0 0; padding: 0; max-height: 340px; overflow: auto; border-top: 1px solid var(--line); }
.lib-item { display: grid; grid-template-columns: 1fr auto 22px; gap: 8px; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 8px 4px; font: inherit; font-size: .93rem; cursor: pointer; color: var(--ink); }
.lib-item:hover { background: var(--paper); }
.lib-h { color: var(--ink-2); font-size: .85rem; }
.lib-plus { color: var(--blue); font-weight: 800; text-align: center; }
.lib-none { padding: 14px 4px; color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 24px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .92rem; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 40; max-width: 92vw; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
dialog { border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; width: min(560px, 92vw); color: var(--ink); }
dialog::backdrop { background: rgba(16,32,58,.5); }
dialog h2 { margin: 0 0 6px; font: 650 1.1rem var(--font); }
dialog textarea { width: 100%; min-height: 120px; font: .85rem/1.5 ui-monospace, Menlo, Consolas, monospace; margin: 8px 0 12px; }

/* content */
.content { padding: 8px 0 30px; }
.content h2 { font: 650 clamp(1.25rem, 1.6vw + .8rem, 1.7rem)/1.25 var(--display); letter-spacing: -.02em; margin: 34px 0 12px; }
.content p, .content li { max-width: 72ch; }
.steps { padding-left: 1.2em; }
.steps li { margin-bottom: 6px; }
.faq details { border-bottom: 1px solid var(--line); padding: 12px 0; max-width: 780px; }
.faq summary { font-weight: 650; cursor: pointer; }
.faq details p { margin: 8px 0 0; color: var(--ink-2); }
.linkgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px; list-style: none; padding: 0; margin: 0; }
.linkgrid a { display: block; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; text-decoration: none; color: var(--ink); font-weight: 550; }
.linkgrid a:hover { border-color: var(--ink); }
.linkgrid small { display: block; color: var(--ink-2); font-weight: 400; }
.facts { font-size: 1.05rem; max-width: 70ch; }
.facts strong { font-weight: 700; }
.dir { columns: 3 230px; column-gap: 24px; list-style: none; padding: 0; margin: 0; }
.dir li { break-inside: avoid; padding: 3px 0; }
.dir small { color: var(--ink-2); }

/* calculators */
.calc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; margin: 6px 0 34px; }
.calc { padding: 18px; }
.calc h2 { font: 650 1.05rem/1.3 var(--font); letter-spacing: 0; margin: 0 0 12px; }
.calc label { display: grid; gap: 4px; font-size: .88rem; font-weight: 600; margin-bottom: 10px; }
.calc .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.calc .out { margin-top: 6px; }
.calc .big { font-weight: 700; font-size: 1.12rem; margin: 6px 0; }
.muted { color: var(--ink-2); font-size: .92rem; }
.things { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.things b { color: var(--blue-ink); }
.btn { display: inline-block; background: var(--blue); color: #fff; text-decoration: none; padding: 9px 16px; border-radius: 999px; font-weight: 650; border: 0; cursor: pointer; font: inherit; font-weight: 650; }
.btn:hover { background: var(--blue-ink); color: #fff; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--paper); color: var(--ink); }

/* photo */
.photo { padding: 16px; }
.drop { display: grid; place-items: center; gap: 10px; min-height: 260px; border: 2px dashed #a9b8cb; border-radius: var(--radius); text-align: center; padding: 24px; color: var(--ink-2); }
.drop.over { border-color: var(--blue); background: rgba(36,71,249,.05); }
#ph-canvas { max-width: 100%; max-height: 78vh; width: auto; height: auto; margin: 0 auto; border-radius: 8px; cursor: crosshair; touch-action: none; display: block; }
.ph-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 12px 0; }
.ph-bar label { display: grid; gap: 4px; font-weight: 600; font-size: .88rem; }
#ph-step { font-weight: 650; padding: 10px 14px; background: #fff8dc; border: 1px solid var(--ruler-deep); border-radius: 10px; margin: 10px 0; }
.ph-out .big { font: 700 1.5rem var(--display); }

.site-foot { border-top: 1px solid var(--line); background: var(--card); padding: 26px 0 40px; color: var(--ink-2); font-size: .92rem; }
.site-foot .langs { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: 10px 0; }
.site-foot p { margin: 6px 0; max-width: 70ch; }

/* embed mode */
body.embed { background: transparent; }
body.embed .studio { grid-template-columns: 1fr; margin: 0; }
body.embed .side, body.embed .toolbar .hide-embed, body.embed .htable-wrap, body.embed .hero, body.embed .content, body.embed .site-head, body.embed .site-foot { display: none; }
body.embed #stage-scroll { max-height: none; }
.embed-foot { text-align: right; font-size: .8rem; padding: 6px 10px; }

@media (max-width: 1020px) {
  .studio { grid-template-columns: 1fr; }
  .people, .lib { max-height: 300px; }
}
@media (max-width: 640px) {
  .toolbar { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .toolbar > * { flex: none; }
  .toolbar .sp { display: none; }
  .head-row { flex-wrap: wrap; }
  .nav { order: 3; flex-basis: 100%; }
  .hero { padding-top: 22px; }
  .toolbar .zoom input { width: 70px; }
  .things { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } .toast { transition: none; } }
@media print { .site-head, .side, .toolbar, .content, .site-foot { display: none; } .studio { display: block; } }
