/* hirosien — base layer. Solid white for every theme; a theme only changes the accent colour. */
:root {
  --bg: #ffffff; --paper: #ffffff; --paper-2: #f4f5f6; --paper-3: #fafafb;
  --ink: #15171a; --ink-2: #3c4046; --muted: #7c8187;
  --line: #ebeef0; --line-2: #dde1e5;
  --accent: #2f7d55; --accent-2: #24643f; --accent-soft: #eaf4ee; --accent-ink: #ffffff;
  --seal: #c8372d; --seal-soft: #fbeceb;
  --ok: #30a46c; --err: #e5484d; --warn: #b7791f; --warn-soft: #fdf5e6;
  --sans: "Pretendard JP Variable", "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont,
    "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Hiragino Sans", "Yu Gothic", sans-serif;
  --serif: var(--sans);
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 6px; --r-sm: 5px; --r-lg: 8px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04);
  --shadow-lg: 0 18px 50px -12px rgba(0, 0, 0, .25);
  --tap: 44px;
}
/* themes = accent colour only */
[data-palette="hirosien"] { --accent: #2f7d55; --accent-2: #24643f; --accent-soft: #eaf4ee; }
[data-palette="hakuji"]   { --accent: #3d6a8e; --accent-2: #2f5574; --accent-soft: #eaf1f7; }
[data-palette="seiji"]    { --accent: #1f8a82; --accent-2: #17706a; --accent-soft: #e5f4f3; }
[data-palette="sakura"]   { --accent: #d6336c; --accent-2: #b5265a; --accent-soft: #fcebf1; }
[data-palette="kaki"]     { --accent: #e0661f; --accent-2: #bf5216; --accent-soft: #fdf0e7; }
[data-palette="fuji"]     { --accent: #6e56cf; --accent-2: #5842b0; --accent-soft: #f1eefc; }
[data-palette="sumi"]     { --accent: #15171a; --accent-2: #000000; --accent-soft: #eef0f2; }
html { -webkit-text-size-adjust: 100%; font-size: 100%; }
html[data-font="large"] { font-size: 112.5%; }
html[data-font="xlarge"] { font-size: 125%; }
*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans);
  font-size: 1rem; line-height: 1.65; letter-spacing: -0.01em; word-break: keep-all; overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
img { max-width: 100%; height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 800; letter-spacing: -0.03em; }
p { margin: 0 0 1em; }
hr { border: 0; border-top: 1px solid var(--line); margin: 24px 0; }
::selection { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hp-field { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }
[hidden] { display: none !important; }

.serif { font-family: var(--serif); }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.nowrap { white-space: nowrap; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack > * + * { margin-top: 12px; }
.grow { flex: 1 1 auto; min-width: 0; }
.mt0 { margin-top: 0 !important; } .mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; } .mt40 { margin-top: 40px; }
.mb0 { margin-bottom: 0 !important; } .mb8 { margin-bottom: 8px; } .mb16 { margin-bottom: 16px; } .mb24 { margin-bottom: 24px; }

.ic { width: 1.15em; height: 1.15em; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6;
  stroke-linecap: round; stroke-linejoin: round; vertical-align: -0.2em; }
.ic.lg { width: 1.5em; height: 1.5em; }
.ic.xl { width: 2em; height: 2em; }

/* ---------- wordmark & seal ---------- */
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); }
.brand:hover { color: var(--ink); }
/* logo mark: a plain black square with 煕 — no stamp effects */
.seal {
  display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; overflow: hidden;
  background: var(--ink); color: #fff; font-weight: 800; font-size: 0; line-height: 1; flex: none;
}
.seal::before { content: "煕"; font-size: 15px; }
.seal.lg { width: 44px; height: 44px; border-radius: 9px; }
.seal.lg::before { font-size: 23px; }
.wordmark { font-weight: 800; font-size: 1.2rem; letter-spacing: -0.04em; }
.wordmark small { font-size: .72rem; color: var(--muted); margin-left: 6px; font-weight: 500; letter-spacing: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  padding: 0 16px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--paper);
  color: var(--ink); font-weight: 600; font-size: .94rem; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s; text-decoration: none; user-select: none;
}
.btn:hover { border-color: #c5cad0; background: var(--paper-3); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); color: var(--accent-ink); }
.btn.ink { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.ink:hover { background: #000; color: #fff; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--paper-2); }
.btn.danger { color: var(--err); }
.btn.danger:hover { border-color: var(--err); background: #fbeceb; }
.btn.danger.solid { background: var(--err); border-color: var(--err); color: #fff; }
.btn.sm { min-height: 32px; padding: 0 11px; font-size: .84rem; }
.btn.lg { min-height: 50px; padding: 0 24px; font-size: 1.02rem; }
.btn.block { width: 100%; }
.btn.icon { padding: 0; width: 40px; }
.btn.icon.sm { width: 32px; }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }

/* ---------- forms ---------- */
.field { display: block; margin-bottom: 18px; }
.field > label, .label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; color: var(--ink-2); }
.field .hint { font-size: .82rem; color: var(--muted); margin-top: 6px; }
.field .error, .form-error { font-size: .85rem; color: var(--err); margin-top: 6px; }
.form-error { background: #fbeceb; border: 1px solid #f0c9c4; padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 16px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 10px 13px; border: 1px solid var(--line-2); border-radius: var(--r-sm);
  background: var(--paper); transition: border-color .15s, box-shadow .15s; font-size: 1rem;
}
textarea.input { min-height: 110px; resize: vertical; line-height: 1.6; }
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.sm { min-height: 34px; padding: 5px 10px; font-size: .9rem; }
select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 32px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
@media (max-width: 720px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 44px; height: 26px; border-radius: 13px; background: var(--line-2); position: relative; transition: background .2s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--r-sm); overflow: hidden; background: var(--paper); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; cursor: pointer; font-size: .9rem; font-weight: 600; color: var(--ink-2); }
.seg label + label span { border-left: 1px solid var(--line-2); }
.seg input:checked + span { background: var(--ink); color: var(--paper); }

/* ---------- chips, badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: .8rem;
  background: var(--paper-2); color: var(--ink-2); border: 1px solid transparent; white-space: nowrap; line-height: 1.6; }
a.chip:hover { border-color: var(--line-2); color: var(--ink); }
.chip.accent { background: var(--accent-soft); color: var(--accent-2); }
.chip.seal { background: var(--seal-soft); color: var(--seal); }
.chip.line { background: transparent; border-color: var(--line-2); }
.badge { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: .72rem; font-weight: 700; letter-spacing: .02em;
  background: var(--paper-2); color: var(--ink-2); vertical-align: middle; }
.badge.ok { background: #e4f0e3; color: #2f6a39; }
.badge.warn { background: var(--warn-soft); color: #8a5a12; }
.badge.err { background: #fbe4e1; color: #a1342a; }
.badge.ink { background: var(--ink); color: var(--paper); }
.tagline { font-family: var(--serif); color: var(--muted); }

/* ---------- flash & toast ---------- */
.flashes { position: fixed; top: 14px; left: 50%; transform: translateX(-50%); z-index: 300; display: grid; gap: 8px; width: min(560px, calc(100% - 24px)); }
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px 12px 16px; border-radius: var(--r); background: var(--ink); color: var(--paper);
  box-shadow: var(--shadow-lg); font-size: .95rem; animation: flash-in .25s ease-out; }
.flash.error { background: #8f2d23; }
.flash .x { margin-left: auto; background: none; border: 0; color: inherit; opacity: .7; cursor: pointer; padding: 0 4px; font-size: 1.1rem; }
@keyframes flash-in { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 400; display: grid; place-items: center; padding: 16px; background: rgba(20, 22, 18, .45); }
.modal[hidden] { display: none; }
.modal-card { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--paper); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); padding: 24px; animation: flash-in .2s ease-out; }
.modal-card.wide { width: min(860px, 100%); }
.modal-card h3 { font-size: 1.15rem; margin-bottom: 6px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
@media (max-width: 560px) {
  .modal { align-items: end; padding: 0; }
  .modal-card { border-radius: 18px 18px 0 0; padding: 22px 18px calc(18px + env(safe-area-inset-bottom)); max-height: 92vh; }
  .modal-actions .btn { flex: 1; }
}

/* ---------- pager ---------- */
.pager { display: flex; justify-content: center; gap: 4px; margin: 36px 0 8px; flex-wrap: wrap; }
.pager a, .pager span { min-width: 38px; height: 38px; display: inline-grid; place-items: center; border-radius: var(--r-sm); font-size: .92rem; color: var(--ink-2); padding: 0 8px; }
.pager a:hover { background: var(--paper-2); color: var(--ink); }
.pager .on { background: var(--ink); color: var(--paper); font-weight: 700; }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: .8rem; letter-spacing: .02em; padding: 10px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: color-mix(in srgb, var(--paper-2) 50%, transparent); }
.table .actions { white-space: nowrap; text-align: right; }

/* ---------- empty ---------- */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .ic { width: 40px; height: 40px; stroke-width: 1.2; margin-bottom: 10px; color: var(--line-2); }
.empty h3 { color: var(--ink-2); font-size: 1.05rem; margin-bottom: 6px; }

/* ---------- error pages ---------- */
.err-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; text-align: center; }
.err-page .code { font-family: var(--serif); font-size: 5rem; line-height: 1; color: var(--line-2); font-weight: 700; }
.err-page h1 { font-family: var(--serif); font-size: 1.6rem; margin: 12px 0 8px; }
