/* Righello.org */
:root {
  --bg: #f6f7fb; --surface: #fff; --surface-2: #eef1f7; --text: #14213d; --muted: #59627a; --line: #dfe3ec;
  --brand: #14213d; --brand-2: #22346b; --accent: #ffc72c; --accent-2: #f2a900; --ok: #15803d; --warn: #b45309;
  --a: #2563eb; --b: #e11d48; --radius: 14px; --shadow: 0 1px 2px rgba(20,33,61,.06), 0 6px 24px rgba(20,33,61,.07);
  --rl-body: #ffc72c; --rl-ink: #1b1b1b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1324; --surface: #141c31; --surface-2: #1b2540; --text: #e8ecf6; --muted: #a3adc4; --line: #27324f;
    --brand: #0a0f1d; --brand-2: #1d2a50; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 17px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--text); background: var(--bg); overflow-x: hidden; }
img { max-width: 100%; height: auto; }
a { color: var(--brand-2); text-underline-offset: 2px; }
@media (prefers-color-scheme: dark) { a { color: #9db8ff; } }
h1, h2, h3 { line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: clamp(1.75rem, 4.2vw, 2.6rem); margin: .2em 0 .25em; }
h2 { font-size: clamp(1.35rem, 2.8vw, 1.75rem); margin: 2.2em 0 .6em; }
h3 { font-size: 1.15rem; margin: 1.6em 0 .4em; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.content { max-width: 780px; margin: 0 auto; padding: 0 16px; }
.small, small { font-size: .85rem; color: var(--muted); }
.muted { color: var(--muted); }
.skip { position: absolute; left: -9999px; } .skip:focus { left: 16px; top: 8px; z-index: 99; background: #fff; color: #14213d; padding: 8px 12px; border-radius: 8px; }

/* header */
.site-header { background: var(--brand); color: #fff; }
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -.01em; }
.logo svg { width: 30px; height: 30px; flex: none; }
.logo-t { white-space: nowrap; } .logo-t b { color: var(--accent); font-weight: 800; }
.nav { margin-left: auto; }
.nav ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 4px; flex-wrap: wrap; }
.nav a { color: #dfe6f7; text-decoration: none; font-size: .93rem; padding: 6px 10px; border-radius: 8px; display: block; }
.nav a:hover, .nav a[aria-current] { background: rgba(255,255,255,.1); color: #fff; }
.menu-btn { display: none; }
@media (max-width: 860px) {
  .nav { position: relative; }
  .menu-btn { display: inline-flex; margin-left: auto; background: rgba(255,255,255,.1); color: #fff; border: 0; border-radius: 10px; padding: 8px 12px; font: inherit; font-size: .95rem; cursor: pointer; }
  .nav ul { display: none; position: absolute; right: 0; top: 46px; z-index: 50; flex-direction: column; background: var(--brand); border-radius: 12px; padding: 8px; min-width: 230px; box-shadow: 0 12px 30px rgba(0,0,0,.35); }
  .nav.open ul { display: flex; }
}

/* hero */
.hero { padding-top: 18px; padding-bottom: 6px; }
.crumbs { font-size: .85rem; color: var(--muted); margin: 0; padding-top: 12px; }
.crumbs a { color: var(--muted); }
.lead { font-size: 1.08rem; color: var(--muted); max-width: 820px; margin: 0 0 6px; }

/* tool */
.tool { margin: 10px 0 8px; }
.tool-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 10px; }
.r-status { margin: 0; font-size: .92rem; }
.st-ok { color: var(--ok); font-weight: 700; } .st-warn { color: var(--warn); font-weight: 700; } .st-sub { color: var(--muted); }
@media (prefers-color-scheme: dark) { .st-ok { color: #4ade80; } .st-warn { color: #fbbf24; } }
.tool-btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 11px; padding: 3px; }
.seg button { border: 0; background: transparent; color: var(--text); font: inherit; font-size: .88rem; padding: 6px 11px; border-radius: 8px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 700; }
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .92rem; font-weight: 600; padding: 8px 14px; border-radius: 11px; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { border-color: var(--brand-2); }
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1b1b1b; }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.link { border: 0; background: none; padding: 0; color: var(--brand-2); text-decoration: underline; font: inherit; cursor: pointer; }
@media (prefers-color-scheme: dark) { .link { color: #9db8ff; } }

/* ruler: .tool sits directly in <main> (full width, no padding), so 100% = visible page width
   and the zero lands exactly on the left edge. (100vw would include the scrollbar and shift it.) */
.rl-host { width: 100%; margin: 0; min-height: calc(var(--T, 124px) + 48px); }
.rl { position: relative; }
.rl-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.rl-inner { position: relative; }
.rl-cv { display: block; box-shadow: 0 2px 0 rgba(0,0,0,.08), 0 10px 24px rgba(20,33,61,.12); cursor: crosshair; touch-action: pan-x pan-y; }
.rl-m { position: absolute; top: 0; left: 0; touch-action: none; cursor: grab; z-index: 2; outline: none; }
.rl-m i { position: absolute; background: var(--mc); pointer-events: none; }
.rl-m b { position: absolute; width: 34px; height: 34px; border-radius: 50%; background: var(--mc); color: #fff; font: 800 15px/34px system-ui, sans-serif; text-align: center; box-shadow: 0 2px 8px rgba(0,0,0,.3); }
.rl-m b::after { content: ""; position: absolute; inset: -10px; }
.rl-m.drag { cursor: grabbing; } .rl-m:focus-visible b { outline: 3px solid var(--text); outline-offset: 2px; }
.rl-a { --mc: var(--a); } .rl-b { --mc: var(--b); }
.rl-h .rl-m { width: 0; height: calc(var(--T) + 48px); }
.rl-h .rl-m i { left: -1px; top: 0; width: 2px; height: var(--T); }
.rl-h .rl-m b { left: -17px; top: calc(var(--T) + 8px); }
.rl-v .rl-m { height: 0; width: calc(var(--T) + 48px); }
.rl-v .rl-m i { top: -1px; left: 0; height: 2px; width: var(--T); }
.rl-v .rl-m b { top: -17px; left: calc(var(--T) + 8px); }
.rl-long .rl-scroll { box-shadow: inset -24px 0 18px -18px rgba(0,0,0,.25); }
.tool-foot { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: baseline; justify-content: space-between; }
.r-read, .fs-read { display: flex; flex-wrap: wrap; gap: 4px 14px; align-items: baseline; font-variant-numeric: tabular-nums; }
.r-read strong, .fs-read strong { font-size: 1.5rem; }
.ro-k { font-weight: 800; color: var(--muted); }
.tool-hint { margin: 0; font-size: .88rem; color: var(--muted); }
.ca { color: var(--a); } .cb { color: var(--b); }
.long-note { font-size: .88rem; color: var(--muted); margin-top: 4px; margin-bottom: 0; }
.tool:not(:has(.rl-long)) .long-note { display: none; }

/* steps + cards */
.steps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 22px 0 0; padding: 0; list-style: none; counter-reset: s; }
.steps li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 14px 56px; position: relative; font-size: .95rem; }
.steps li::before { counter-increment: s; content: counter(s); position: absolute; left: 14px; top: 14px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #1b1b1b; font-weight: 800; display: grid; place-items: center; }
.steps b { display: block; }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr; } }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; margin: 14px 0; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: var(--text); box-shadow: var(--shadow); transition: transform .12s ease; }
.card:hover { transform: translateY(-2px); border-color: var(--accent-2); }
.card strong { display: block; font-size: 1.02rem; margin-bottom: 2px; }
.card span { font-size: .88rem; color: var(--muted); }
.card img { border-radius: 8px; margin-bottom: 8px; border: 1px solid var(--line); background: #fff; }

/* content */
.content p, .content li { color: var(--text); }
.content ul, .content ol { padding-left: 1.3em; }
.content li { margin: .3em 0; }
.figure { margin: 20px 0; } .figure img { border-radius: 12px; border: 1px solid var(--line); background: #fff; }
.figure figcaption { font-size: .85rem; color: var(--muted); margin-top: 6px; }
table { width: 100%; border-collapse: collapse; margin: 14px 0; font-variant-numeric: tabular-nums; background: var(--surface); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
th, td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; font-size: .95rem; }
th { background: var(--surface-2); font-weight: 700; }
tr:last-child td { border-bottom: 0; }
.tbl-wrap { overflow-x: auto; }
.cols-2 { columns: 2; column-gap: 16px; } .cols-2 table { break-inside: avoid; }
@media (max-width: 640px) { .cols-2 { columns: 1; } }
.note { background: var(--surface); border-left: 4px solid var(--accent); padding: 12px 16px; border-radius: 0 12px 12px 0; margin: 16px 0; box-shadow: var(--shadow); }
.faq details { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; padding: 0 16px; }
.faq summary { cursor: pointer; font-weight: 700; padding: 14px 0; list-style: none; position: relative; padding-right: 28px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 0; top: 10px; font-size: 1.4rem; color: var(--muted); }
.faq details[open] summary::after { content: "–"; }
.faq details > div { padding-bottom: 12px; }
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; margin: 16px 0; }
.dl .card { text-align: left; }
.dl .btn { margin-top: 8px; }

/* converter */
.conv { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: end; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin: 14px 0; }
.conv label { display: grid; gap: 4px; font-weight: 700; font-size: .92rem; }
.conv input { font: inherit; font-size: 1.4rem; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--text); width: 100%; font-variant-numeric: tabular-nums; }
.conv-eq { font-size: 1.6rem; font-weight: 800; padding-bottom: 10px; color: var(--muted); }
.conv-out { grid-column: 1 / -1; margin: 4px 0 0; font-size: 1.05rem; }
@media (max-width: 520px) { .conv { grid-template-columns: 1fr; } .conv-eq { display: none; } }

/* calibration dialog */
dialog.cal { border: 0; padding: 0; border-radius: 18px; width: min(680px, calc(100vw - 16px)); max-height: calc(100vh - 16px); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.4); }
dialog.cal::backdrop { background: rgba(10,15,29,.6); }
dialog.cal[open]:not(:modal) { position: fixed; inset: 8px; margin: auto; z-index: 1001; }
.cal-in { padding: 16px 18px 14px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; }
.cal-head h2 { margin: 0; font-size: 1.3rem; }
.cal-x { border: 0; background: var(--surface-2); color: var(--text); width: 36px; height: 36px; border-radius: 50%; font-size: 1rem; cursor: pointer; }
.cal-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.cal-tabs button { border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; padding: 6px 12px; border-radius: 999px; cursor: pointer; }
.cal-tabs button[aria-selected="true"] { background: var(--brand-2); color: #fff; border-color: var(--brand-2); }
.cal section p { margin: 0 0 10px; font-size: .95rem; }
.cal-adj { display: flex; gap: 8px; align-items: center; margin: 8px 0 12px; }
.cal-adj input { flex: 1; accent-color: var(--brand-2); }
.cal-adj .btn { width: 44px; justify-content: center; font-size: 1.2rem; padding: 6px; }
.cal-stage { padding: 2px; margin-bottom: 12px; overflow: hidden; }
.cal-card { border: 2px solid var(--a); border-radius: 3.2mm; background: repeating-linear-gradient(45deg, rgba(37,99,235,.06) 0 10px, transparent 10px 20px); display: grid; place-items: center; }
.cal-card span { font-size: .8rem; color: var(--muted); }
.cal-card.portrait span { writing-mode: vertical-rl; }
.cal-coin { border: 2px solid var(--a); border-radius: 50%; position: relative; background: rgba(37,99,235,.06); }
.cal-coin::after { content: attr(data-l); position: absolute; left: calc(100% + 10px); top: 50%; transform: translateY(-50%); white-space: nowrap; font-size: .85rem; color: var(--muted); }
.cal-line { margin: 8px 0 14px; }
.cal-line i { display: block; height: 0; border-top: 3px solid var(--a); position: relative; }
.cal-line i::before, .cal-line i::after { content: ""; position: absolute; top: -10px; width: 2px; height: 17px; background: var(--a); }
.cal-line i::before { left: 0; } .cal-line i::after { right: 0; }
.cal-line span { font-size: .85rem; color: var(--muted); }
.cal-save { margin: 0 0 12px; }
@media (max-width: 560px) {
  dialog.cal { width: 100vw; max-width: 100vw; height: 100%; max-height: 100%; margin: 0; border-radius: 0; }
  .cal-in { padding: 12px; }
  .cal section p { font-size: .9rem; }
}
.cal-foot { display: flex; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.chip { border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: .88rem; padding: 5px 11px; border-radius: 999px; cursor: pointer; }
.chip[aria-pressed="true"], .chip:hover { border-color: var(--brand-2); background: var(--surface-2); }
.fld { display: grid; gap: 4px; font-weight: 700; font-size: .92rem; margin-bottom: 10px; }
.fld input, .fld select { font: inherit; font-weight: 400; padding: 9px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); max-width: 100%; }

/* full screen overlay */
.fs { position: fixed; inset: 0; z-index: 1000; background: var(--bg); display: flex; }
.fs[hidden] { display: none; }
html.fs-open, html.fs-open body { overflow: hidden; }
.fs-h { flex-direction: column; }
.fs-v { flex-direction: row; }
.fs-ruler { flex: none; }
.fs-h .fs-ruler { width: 100%; }
.fs-v .fs-ruler { height: 100%; }
.fs-v .fs-ruler .rl-scroll { height: 100%; overflow-x: hidden; overflow-y: auto; }
.fs-v .fs-ruler .rl, .fs-v .fs-ruler { height: 100%; }
.fs-panel { padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; overflow: auto; min-width: 0; flex: 1; }
.fs-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.fs-tip, .fs-st { margin: 0; font-size: .9rem; color: var(--muted); }
.fs-v .fs-read { flex-direction: column; gap: 2px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 1100; box-shadow: var(--shadow); transition: opacity .4s, transform .4s; }
.toast.out { opacity: 0; transform: translate(-50%, 10px); }

/* footer */
.site-footer { background: var(--brand); color: #c9d2e8; margin-top: 64px; padding: 32px 0 26px; font-size: .92rem; }
.site-footer a { color: #fff; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.foot-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 24px; }
.foot-grid ul { list-style: none; padding: 0; margin: 6px 0 0; }
.foot-grid li { margin: 5px 0; }
.foot-grid h3 { color: #fff; font-size: .95rem; margin: 0; }
.foot-copy { margin-top: 22px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.12); font-size: .82rem; }
@media (max-width: 720px) { .foot-grid { grid-template-columns: 1fr 1fr; } .foot-grid > div:first-child { grid-column: 1 / -1; } }
@media print { .site-header, .site-footer, .tool { display: none; } }
