/* ナベサン句会 — 和紙と墨と朱印 */
:root {
  --paper: #f5f0e6;
  --paper-2: #ece4d4;
  --card: #fffcf6;
  --ink: #26211d;
  --ink-2: #554e47;
  --ink-3: #887f75;
  --line: #e2d8c5;
  --line-2: #cdbfa6;
  --shu: #b7371f;
  --shu-d: #8f2814;
  --shu-soft: #f8e4db;
  --ai: #2b4a6f;
  --ai-d: #1d3553;
  --ai-soft: #e2e9f2;
  --moss: #4f6a2c;
  --moss-soft: #e8eed9;
  --gold: #9b7a2f;
  --mincho: "Shippori Mincho", "Hiragino Mincho ProN", "Hiragino Mincho Pro", "Yu Mincho", "YuMincho", "Noto Serif JP", "Noto Serif CJK JP", serif;
  --gothic: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Noto Sans CJK JP", "Yu Gothic UI", "Meiryo", sans-serif;
  --r: 14px;
  --shadow: 0 1px 0 rgba(70, 45, 20, .04), 0 10px 24px -18px rgba(70, 45, 20, .45);
  --top-h: 58px;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html[data-size="l"] { font-size: 18px; }
html[data-size="xl"] { font-size: 20px; }
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  font-family: var(--gothic);
  line-height: 1.7;
  background-color: var(--paper);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .42 0 0 0 0 .32 0 0 0 0 .18 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--ai); }
h1, h2, h3 { font-family: var(--mincho); font-weight: 700; letter-spacing: .06em; line-height: 1.4; }
h2 { font-size: 1.2rem; margin: 0 0 .6em; }
h3 { font-size: 1.05rem; margin: 1.2em 0 .5em; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--ai); outline-offset: 2px; }
[hidden] { display: none !important; }
.muted { color: var(--ink-3); }
.loading { text-align: center; color: var(--ink-3); padding: 4rem 0; font-family: var(--mincho); letter-spacing: .3em; }

/* ---------- 上部バー・ナビ ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--top-h);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-right));
  background: rgba(245, 240, 230, .88);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; text-decoration: none; color: var(--ink); min-width: 0; }
.seal {
  display: inline-grid; place-items: center; flex: none;
  width: 32px; height: 32px; border-radius: 6px;
  background: var(--shu); color: #fbf4ea;
  font-family: var(--mincho); font-weight: 700; font-size: 19px;
  box-shadow: inset 0 0 0 2px var(--shu), inset 0 0 0 3.5px rgba(251, 244, 234, .9);
}
.seal.big { width: 64px; height: 64px; font-size: 38px; border-radius: 10px; box-shadow: inset 0 0 0 4px var(--shu), inset 0 0 0 6px rgba(251, 244, 234, .9); }
.brand-name { font-family: var(--mincho); font-weight: 700; font-size: 1.15rem; letter-spacing: .14em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav { margin-left: auto; display: flex; gap: .2rem; }
.nav a {
  display: flex; align-items: center; gap: .35rem;
  padding: .45rem .75rem; border-radius: 999px;
  color: var(--ink-2); text-decoration: none; font-size: .92rem;
}
.nav a svg { width: 18px; height: 18px; }
.nav a.on { color: var(--ink); background: var(--paper-2); font-weight: 600; }
.nav a:hover { color: var(--ink); }

.main { max-width: 880px; margin: 0 auto; padding: 18px 16px 48px; }

@media (max-width: 759px) {
  /* backdrop-filterがあると固定表示のタブバーが見出しの中に閉じ込められるため外す */
  .topbar { backdrop-filter: none; -webkit-backdrop-filter: none; background: var(--paper); }
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    background: rgba(250, 246, 238, .96);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid var(--line);
    gap: 0;
  }
  .nav a { flex: 1; flex-direction: column; justify-content: center; gap: 2px; border-radius: 0; font-size: .7rem; padding: 0; }
  .nav a svg { width: 23px; height: 23px; }
  .nav a.on { background: none; color: var(--shu); }
  .main { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 32px); }
}

/* ---------- 共通部品 ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 18px;
  margin: 0 0 16px;
  box-shadow: var(--shadow);
}
.card.subtle { background: transparent; box-shadow: none; border-style: dashed; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.card-head h2 { margin: 0; }
.page-title { font-size: 1.5rem; margin: .4rem 0 1rem; }
.sec { font-size: 1.05rem; margin: 1.8rem 0 .8rem; display: flex; align-items: center; gap: .6rem; color: var(--ink-2); }
.sec::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.empty { color: var(--ink-3); margin: .6rem 0; }
.hint { color: var(--ink-3); font-size: .86rem; margin: .5rem 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 44px; padding: .5em 1.25em;
  border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--card); color: var(--ink);
  text-decoration: none; cursor: pointer; font-weight: 600; font-size: .95rem;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ink); border-color: var(--ink); color: #fbf6ec; }
.btn.primary:hover { background: #3a332d; }
.btn.ok { background: var(--moss); border-color: var(--moss); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--shu); border-color: #e3b6aa; }
.btn.small { min-height: 34px; padding: .2em .9em; font-size: .85rem; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: .5rem; margin: .4rem 0; }
.icon-btn { border: none; background: transparent; width: 44px; height: 44px; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); font-size: 1.4rem; }
.icon-btn:hover { background: var(--paper-2); }
.icon-btn svg { width: 20px; height: 20px; }
.link-btn { border: none; background: none; color: var(--ai); cursor: pointer; padding: .2em .3em; font-size: .85rem; }
.link-btn.danger { color: var(--shu); }

.tag {
  display: inline-block; padding: 0 .55em; margin: 0 .15em;
  border: 1px solid var(--line-2); border-radius: 4px;
  font-family: var(--mincho); font-size: .9em; background: var(--paper);
}
.tag.small { font-size: .78rem; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { display: inline-flex; align-items: center; gap: .3em; padding: .1em .65em .1em .2em; border-radius: 999px; background: var(--paper-2); font-size: .9rem; }
.chip b { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 50%; background: var(--ink); color: var(--paper); font-family: var(--mincho); font-weight: 700; }
.chip.off { opacity: .45; }

.kanji-badge {
  display: inline-grid; place-items: center; flex: none;
  width: 1.9em; height: 1.9em; border-radius: 6px;
  background: var(--ink); color: var(--paper);
  font-family: var(--mincho); font-weight: 700; line-height: 1; vertical-align: middle;
}
.kanji-badge.sm { width: 1.55em; height: 1.55em; font-size: .82em; border-radius: 4px; margin-left: .3em; }
.kanji-badge.big { width: 2.4em; height: 2.4em; font-size: 1.5rem; border-radius: 10px; }

/* フォーム */
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: .85rem; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }
.field small { color: var(--ink-3); font-weight: normal; }
input[type=text], input[type=password], input[type=date], input[type=datetime-local], input[type=number], input:not([type]), select, textarea {
  width: 100%; min-height: 46px;
  padding: .55em .8em;
  border: 1px solid var(--line-2); border-radius: 10px;
  background: #fffefb;
  font-size: 1rem;
}
textarea { line-height: 1.7; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ai); box-shadow: 0 0 0 3px var(--ai-soft); }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 12px; }
.grid2 > *, .grid3 > * { min-width: 0; }
input, select, textarea { max-width: 100%; }
@media (max-width: 559px) {
  .grid3 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .grid2.wide-sm { grid-template-columns: minmax(0, 1fr); }
}
.check { display: flex; align-items: center; gap: .5em; margin: .3em 0 .8em; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }
.radio-row { display: flex; flex-wrap: wrap; gap: .4em 1.2em; }
fieldset { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 4px; margin: 0 0 14px; min-width: 0; }
legend { font-weight: 600; font-size: .9rem; padding: 0 .4em; color: var(--ink-2); }

/* ---------- ログイン・初期設定 ---------- */
.auth { max-width: 460px; margin: 4vh auto 0; }
.auth-brand { text-align: center; margin-bottom: 1.4rem; }
.auth-brand h1 { font-size: 1.9rem; letter-spacing: .25em; margin: .7rem 0 .1rem; }
.auth-brand p { margin: 0; color: var(--ink-3); letter-spacing: .3em; font-family: var(--mincho); }
.kanji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 10px; margin: 1rem 0; }
.kanji-btn {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--line-2); background: #fffefb; cursor: pointer;
  font-family: var(--mincho); font-weight: 700; font-size: 1.9rem;
}
.kanji-btn.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.pin-input { text-align: center; font-size: 1.6rem !important; letter-spacing: .5em; }
.login-who { display: flex; align-items: center; gap: .6rem; margin: .6rem 0; font-weight: 600; }
.kanji-input { font-family: var(--mincho); font-size: 1.4rem !important; text-align: center; max-width: 5em; }

/* ---------- ホーム ---------- */
.welcome { display: flex; align-items: center; gap: 14px; margin: .4rem 0 1.2rem; }
.welcome-hi { font-family: var(--mincho); font-size: 1.25rem; font-weight: 700; letter-spacing: .06em; }
.kcards { display: grid; gap: 12px; }
.kcard {
  display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--ink-3); }
.kcard.st-submission::before { background: var(--moss); }
.kcard.st-selection::before { background: var(--shu); }
.kcard-date { font-size: .85rem; color: var(--ink-3); }
.kcard-title { font-family: var(--mincho); font-size: 1.3rem; font-weight: 700; letter-spacing: .06em; margin: .1rem 0 .3rem; }
.kcard-row { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; font-size: .9rem; }
.kcard-cta { margin-top: .6rem; font-weight: 600; font-size: .95rem; display: flex; justify-content: space-between; gap: .5rem; align-items: center; }
.kcard-cta .arrow { color: var(--ink-3); }
.phase { display: inline-block; font-size: .78rem; font-weight: 700; padding: .1em .7em; border-radius: 999px; letter-spacing: .08em; }
.phase.submission { background: var(--moss-soft); color: var(--moss); }
.phase.selection { background: var(--shu-soft); color: var(--shu-d); }
.phase.revealed { background: var(--paper-2); color: var(--ink-2); }
.past { list-style: none; padding: 0; margin: 0; border-top: 1px solid var(--line); }
.past li a { display: grid; grid-template-columns: auto 1fr auto; gap: .2rem 1rem; align-items: baseline; padding: .8rem .2rem; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.past .p-date { color: var(--ink-3); font-size: .85rem; font-variant-numeric: tabular-nums; }
.past .p-title { font-family: var(--mincho); font-weight: 600; }
.past .p-kd { color: var(--ink-3); font-size: .85rem; text-align: right; }
.onboard { border-left: 4px solid var(--shu); }
.onboard ol { margin: .4rem 0 0; padding-left: 1.3em; }

/* ---------- 句会ページ ---------- */
.crumb { display: flex; justify-content: space-between; align-items: center; margin: -6px 0 2px; }
.crumb a { text-decoration: none; color: var(--ink-2); font-size: .9rem; }
.khead { margin-bottom: 14px; }
.khead-date { color: var(--ink-3); font-size: .9rem; }
.khead-title { font-size: 1.7rem; margin: .1rem 0 .4rem; }
.kendai { margin: .2rem 0 .6rem; color: var(--ink-2); font-size: .9rem; }
.kendai .tag { font-size: 1.05rem; }
.rules { font-size: .85rem; color: var(--ink-2); }
.deadline { display: inline-block; margin-top: .2rem; font-size: .85rem; color: var(--shu-d); font-weight: 600; }
.note { margin-top: .6rem; padding: .7rem .9rem; background: var(--paper-2); border-radius: 10px; font-size: .9rem; white-space: pre-wrap; word-break: break-word; }

.stepper { display: flex; list-style: none; padding: 0; margin: .9rem 0 .7rem; counter-reset: st; }
.stepper li { flex: 1; position: relative; text-align: center; font-size: .82rem; color: var(--ink-3); font-weight: 600; letter-spacing: .1em; }
.stepper li::before {
  counter-increment: st; content: counter(st);
  display: grid; place-items: center; margin: 0 auto 4px;
  width: 30px; height: 30px; border-radius: 50%;
  border: 1.5px solid var(--line-2); background: var(--paper); position: relative; z-index: 1;
  font-family: var(--mincho);
}
.stepper li::after { content: ""; position: absolute; top: 15px; left: calc(-50% + 15px); right: calc(50% + 15px); height: 1.5px; background: var(--line-2); }
.stepper li:first-child::after { display: none; }
.stepper li.done { color: var(--moss); }
.stepper li.done::before { content: "✓"; font-family: var(--gothic); background: var(--moss); border-color: var(--moss); color: #fff; }
.stepper li.done::after, .stepper li.current::after { background: var(--moss); }
.stepper li.current { color: var(--ink); }
.stepper li.current::before { background: var(--ink); border-color: var(--ink); color: var(--paper); box-shadow: 0 0 0 4px var(--paper-2); }

.admin-panel { border: 1px dashed var(--line-2); border-radius: var(--r); padding: 0 14px; margin: 0 0 16px; background: rgba(255, 252, 246, .6); }
.admin-panel summary { cursor: pointer; padding: 12px 0; font-weight: 700; color: var(--ink-2); list-style: none; display: flex; align-items: center; gap: .4rem; }
.admin-panel summary::-webkit-details-marker { display: none; }
.admin-panel summary::before { content: "▸"; transition: transform .2s; }
.admin-panel[open] summary::before { transform: rotate(90deg); }
.admin-body { padding-bottom: 12px; }
.proxy-banner { background: var(--ai); color: #fff; border-radius: 10px; padding: .6rem .9rem; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center; gap: .6rem; font-weight: 600; }
.proxy-banner button { background: rgba(255, 255, 255, .15); color: #fff; border: 1px solid rgba(255, 255, 255, .4); border-radius: 999px; padding: .2rem .8rem; cursor: pointer; }

/* 投句 */
.counter { font-family: var(--mincho); font-weight: 700; font-size: 1.1rem; }
.counter.full { color: var(--moss); }
.myku { list-style: none; counter-reset: my; padding: 0; margin: .8rem 0; }
.myku li { counter-increment: my; display: flex; align-items: center; gap: .6rem; padding: .7rem 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.myku li::before { content: counter(my); font-family: var(--mincho); color: var(--ink-3); width: 1.4em; text-align: center; }
.myku .ku-inline { font-family: var(--mincho); font-size: clamp(1.08rem, 4.4vw, 1.2rem); letter-spacing: .05em; flex: 1; min-width: 12em; }
.myku .acts { display: flex; gap: .2rem; margin-left: auto; }
.myku form { flex: 1; display: flex; gap: .4rem; flex-wrap: wrap; }
.myku form input { flex: 1; min-width: 12em; font-family: var(--mincho); }
.ku-form { display: grid; gap: 8px; margin-top: .6rem; }
.ku-input-wrap { position: relative; }
.ku-input { font-family: var(--mincho); font-size: 1.25rem !important; padding-right: 3.6em !important; letter-spacing: .04em; }
.len { position: absolute; right: .8em; top: 50%; transform: translateY(-50%); color: var(--ink-3); font-size: .8rem; pointer-events: none; }
.done-msg { background: var(--moss-soft); color: var(--moss); border-radius: 10px; padding: .6rem .9rem; font-weight: 600; }
.bulk { margin-top: 12px; }
.bulk summary { cursor: pointer; color: var(--ai); font-size: .9rem; }
.bulk form { display: grid; gap: 8px; margin-top: 8px; }
.bulk textarea { font-family: var(--mincho); font-size: 1.1rem; }

/* 選句バー */
.selbar {
  position: sticky; top: calc(var(--top-h) + 6px); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: .6rem;
  padding: 8px 8px 8px 16px; margin: 0 0 12px;
  background: rgba(255, 252, 246, .94); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line-2); border-radius: 999px; box-shadow: var(--shadow);
}
.selcount { display: flex; align-items: center; gap: .35rem; font-size: 1rem; white-space: nowrap; }
.selcount b { font-family: var(--mincho); font-size: 1.25rem; }
.selcount .sep { width: .6rem; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: 8px; }
.seg { display: inline-flex; background: var(--paper-2); border-radius: 999px; padding: 3px; }
.seg button { border: none; background: transparent; padding: .35em .95em; border-radius: 999px; cursor: pointer; font-size: .88rem; color: var(--ink-2); min-height: 36px; }
.seg button.on { background: var(--card); color: var(--ink); font-weight: 700; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.tools { display: flex; gap: .3rem; }
.tool { border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: .3em .9em; min-height: 36px; cursor: pointer; font-size: .85rem; }

/* 句カード */
.kulist { display: grid; gap: 10px; }
.ku-card {
  position: relative;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 12px 14px 8px 16px;
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: start;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.ku-card > .ku-text, .ku-card > .ku-author, .ku-card > .ku-sel, .ku-card > .ku-foot, .ku-card > .ku-top { grid-column: 2; }
.ku-no {
  grid-row: 1 / span 3;
  display: grid; place-items: center;
  min-width: 2.1em; height: 2.1em; padding: 0 .3em; border-radius: 999px;
  border: 1px solid var(--line-2); color: var(--ink-2);
  font-family: var(--mincho); font-weight: 700; font-size: .95rem; font-variant-numeric: tabular-nums;
}
.ku-text { font-family: var(--mincho); font-size: clamp(1.12rem, 4.6vw, 1.38rem); letter-spacing: .06em; line-height: 1.65; overflow-wrap: anywhere; padding-top: .05em; text-wrap: balance; }
.ku-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; min-height: 44px; }
.ku-card.mine { background: repeating-linear-gradient(135deg, var(--card) 0 12px, #f8f3e8 12px 24px); }
.mine-label { font-size: .8rem; color: var(--ink-3); border: 1px dashed var(--line-2); border-radius: 999px; padding: 0 .7em; }
.ku-card.sel-toku { border-color: var(--shu); box-shadow: inset 0 0 0 1px var(--shu), var(--shadow); background: linear-gradient(180deg, #fffaf6, var(--card)); }
.ku-card.sel-nami { border-color: var(--ai); box-shadow: inset 0 0 0 1px var(--ai), var(--shadow); background: linear-gradient(180deg, #f8fafd, var(--card)); }
.ku-card.flash { animation: flash 2.2s ease; }
@keyframes flash { 0%, 40% { box-shadow: 0 0 0 4px var(--gold); } 100% { box-shadow: var(--shadow); } }

.stamp {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1.6px solid currentColor; background: transparent; cursor: pointer;
  font-family: var(--mincho); font-weight: 700; font-size: 1.15rem; line-height: 1;
  display: inline-grid; place-items: center;
  transition: transform .15s ease, background .15s ease;
}
.stamp.toku { color: var(--shu); }
.stamp.nami { color: var(--ai); }
.stamp.on { color: #fff8f0; transform: rotate(-8deg); animation: stamp .25s ease; }
.stamp.toku.on { background: var(--shu); border-color: var(--shu-d); box-shadow: inset 0 0 0 2px var(--shu), inset 0 0 0 3.5px rgba(255, 248, 240, .85); }
.stamp.nami.on { background: var(--ai); border-color: var(--ai-d); box-shadow: inset 0 0 0 2px var(--ai), inset 0 0 0 3.5px rgba(255, 248, 240, .85); }
@keyframes stamp { 0% { transform: scale(1.35) rotate(0); opacity: .4; } 100% { transform: scale(1) rotate(-8deg); opacity: 1; } }
.stamp-mini {
  display: inline-grid; place-items: center; width: 1.45em; height: 1.45em; border-radius: 50%;
  color: #fff; font-family: var(--mincho); font-weight: 700; font-size: .8em; line-height: 1; vertical-align: middle; margin-right: .2em;
}
.stamp-mini.toku { background: var(--shu); }
.stamp-mini.nami { background: var(--ai); }

.cbtn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  border: none; background: transparent; color: var(--ink-2); cursor: pointer;
  min-height: 44px; padding: 0 6px; font-size: .85rem; border-radius: 10px;
}
.cbtn:hover { background: var(--paper-2); }
.cbtn svg { width: 19px; height: 19px; }
.cbtn .n { font-weight: 700; }
.cbtn .new, .new-badge { font-style: normal; background: var(--shu); color: #fff; font-size: .68rem; border-radius: 4px; padding: 0 4px; font-weight: 700; }
.edit-ku { border: none; background: none; color: var(--ink-3); cursor: pointer; font-size: .8rem; padding: 0 4px; min-height: 32px; }

/* 縦書き表示 */
.kulist.vertical { grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr)); direction: rtl; }
.kulist.vertical > * { direction: ltr; }
.kulist.vertical .ku-card { grid-template-columns: 1fr; justify-items: center; text-align: center; padding: 12px 8px 6px; }
.kulist.vertical .ku-card > * { grid-column: 1 !important; grid-row: auto !important; }
.kulist.vertical .ku-text { writing-mode: vertical-rl; text-orientation: mixed; height: 15.5em; font-size: 1.3rem; letter-spacing: .12em; margin: 6px 0; text-align: start; padding: 0; }
.kulist.vertical .ku-foot { justify-content: center; }
.kulist.vertical .cbtn { margin-left: 0; }
.kulist.vertical .ku-top { justify-content: center; }
.kulist.vertical .ku-author { justify-content: center; }
.kulist.vertical .ku-sel { text-align: center; }

/* 披講後 */
.result-actions { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 12px; }
@media (max-width: 559px) { .result-actions .btn { min-height: 40px; padding: .3em .85em; font-size: .86rem; } }
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--line-2); margin: 0 0 14px; overflow-x: auto; }
.tabs a { padding: .6rem 1rem; text-decoration: none; color: var(--ink-3); font-weight: 600; white-space: nowrap; border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--ink); border-bottom-color: var(--shu); }
.ku-top { display: flex; align-items: center; gap: .6rem; margin-bottom: -2px; }
.rank { font-family: var(--mincho); font-weight: 700; font-size: .85rem; color: var(--ink-2); }
.rank.r1 { color: var(--shu); }
.pts { margin-left: auto; font-size: .85rem; color: var(--ink-2); white-space: nowrap; }
.pts b { font-family: var(--mincho); font-size: 1.35rem; color: var(--ink); margin-right: 1px; }
.ku-card.scored .pts b { color: var(--shu-d); }
.ku-author { display: flex; align-items: center; justify-content: flex-end; gap: .2rem; font-family: var(--mincho); font-weight: 700; font-size: 1.05rem; letter-spacing: .1em; }
.ku-sel { font-size: .85rem; color: var(--ink-2); line-height: 2; }
.ku-sel .grp { margin-right: .8em; white-space: nowrap; }
.author-block { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; margin-bottom: 12px; box-shadow: var(--shadow); }
.author-block header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: .4rem; border-bottom: 1px solid var(--line); padding-bottom: 8px; margin-bottom: 4px; }
.author-block h3 { margin: 0; font-size: 1.2rem; display: flex; align-items: center; gap: .3rem; }
.author-block .sum { font-size: .9rem; color: var(--ink-2); }
.author-block .sum b { font-family: var(--mincho); font-size: 1.3rem; color: var(--shu-d); }
.author-ku { list-style: none; padding: 0; margin: 0; }
.author-ku li { display: grid; grid-template-columns: 1fr auto; gap: 0 .8rem; padding: .55rem 0; border-bottom: 1px dashed var(--line); align-items: center; }
.author-ku li:last-child { border-bottom: none; }
.author-ku .ku-inline { font-family: var(--mincho); font-size: clamp(1.05rem, 4.2vw, 1.15rem); letter-spacing: .04em; text-wrap: balance; }
.author-ku .cbtn .lbl { display: none; }
.author-ku .ku-sel { grid-column: 1; }
.author-ku .cbtn { grid-column: 2; grid-row: 1 / span 2; }
.ku-inline .no { font-size: .8rem; color: var(--ink-3); margin-right: .5em; font-family: var(--gothic); }
.sel-list { list-style: none; padding: 0; margin: .2rem 0 .6rem; }
.sel-list li { padding: .3rem 0; font-family: var(--mincho); font-size: 1.05rem; display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; }
.sel-list .by { font-family: var(--gothic); font-size: .82rem; color: var(--ink-3); }

/* ---------- コメント（下から出るシート） ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(30, 20, 10, .38);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } }
.sheet {
  width: min(720px, 100%); max-height: 92vh; max-height: 92dvh;
  background: var(--paper); border-radius: 18px 18px 0 0;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .25);
  animation: up .22s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .5; } }
@media (min-width: 760px) { .modal-backdrop { align-items: center; } .sheet { border-radius: 18px; max-height: 86vh; } }
.modal-backdrop.static, .modal-backdrop.static .sheet { animation: none; }
.sheet-head { display: flex; align-items: flex-start; gap: .6rem; padding: 14px 10px 12px 18px; border-bottom: 1px solid var(--line); background: var(--card); }
.sheet-head > div { flex: 1; min-width: 0; }
.sheet-ku { font-family: var(--mincho); font-size: 1.15rem; letter-spacing: .04em; line-height: 1.6; text-wrap: balance; }
.sheet-admin { margin-top: 2px; }
.sheet-ku .ku-no { display: inline-grid; margin-right: .5em; vertical-align: middle; font-size: .8rem; }
.thread { overflow-y: auto; padding: 4px 18px 12px; flex: 1; -webkit-overflow-scrolling: touch; }
.cmt { padding: 10px 0 6px calc(min(var(--depth, 0), 4) * 16px); border-top: 1px solid var(--line); position: relative; }
.cmt.reply::before { content: ""; position: absolute; left: calc(min(var(--depth, 0), 4) * 16px - 9px); top: 12px; bottom: 8px; width: 2px; background: var(--line-2); border-radius: 2px; }
.cmt-head { display: flex; align-items: center; gap: .35rem; flex-wrap: wrap; font-size: .85rem; }
.who { font-weight: 700; }
.who.author, .who-tag { color: var(--shu-d); border: 1px solid var(--shu); border-radius: 4px; padding: 0 .45em; font-size: .78rem; font-weight: 700; background: var(--shu-soft); }
.cmt-time { color: var(--ink-3); font-size: .78rem; }
.cmt-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: .25rem 0 .1rem; font-size: .98rem; }
.cmt-body.deleted { color: var(--ink-3); font-style: italic; }
.cmt-acts { display: flex; gap: .2rem; }
.cmt-edit { display: grid; gap: 6px; margin: .3rem 0; }
.composer { border-top: 1px solid var(--line); background: var(--card); padding: 10px 14px calc(10px + var(--safe-b)); display: grid; gap: 8px; }
.composer textarea { min-height: 70px; max-height: 40vh; }
.composer-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; }
.composer-row .hint { margin: 0; }
.replying { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--ai); font-weight: 600; }
.replying button { border: none; background: var(--ai-soft); color: var(--ai); border-radius: 999px; padding: 0 .7em; cursor: pointer; }

/* ---------- 披講モード ---------- */
body.hiko-open { background: #1c1916; }
body.hiko-open .topbar { display: none; }
body.hiko-open .main { max-width: none; padding: 0; }
.hiko { min-height: 100vh; min-height: 100dvh; color: #f3ebdc; display: flex; flex-direction: column; background: radial-gradient(ellipse at 50% 30%, #2c2621, #1c1916 70%); }
.hiko-top { display: flex; align-items: center; gap: .8rem; padding: 12px 16px; font-size: .9rem; color: #bfb3a0; }
.hiko-top a, .hiko-top .cnt { flex: none; white-space: nowrap; }
.hiko-top a { color: #f3ebdc; text-decoration: none; border: 1px solid #5a5047; border-radius: 999px; padding: .3rem .9rem; }
.hiko-top select { flex: 0 1 auto; width: auto; min-width: 0; min-height: 36px; background: #2c2621; color: #f3ebdc; border-color: #5a5047; margin-left: auto; font-size: .85rem; }
.tcy { text-combine-upright: all; -webkit-text-combine: horizontal; }
.hiko-stage { flex: 1; display: flex; flex-direction: row-reverse; align-items: center; justify-content: center; gap: clamp(1.2rem, 4vw, 3.5rem); padding: 1rem; cursor: pointer; user-select: none; }
.hiko-no { writing-mode: vertical-rl; font-family: var(--mincho); color: #bfb3a0; font-size: 1.1rem; letter-spacing: .3em; align-self: flex-start; margin-top: 6vh; }
.hiko-ku { writing-mode: vertical-rl; font-family: var(--mincho); font-weight: 600; font-size: 3rem; letter-spacing: .1em; max-height: 76vh; line-height: 1.5; }
.hiko-side { writing-mode: vertical-rl; display: flex; gap: 1.2rem; align-self: stretch; justify-content: flex-end; padding-bottom: 6vh; }
.hiko-sel, .hiko-name { opacity: 0; transition: opacity .6s ease, transform .6s ease; transform: translateY(14px); font-family: var(--mincho); }
.hiko-sel.show, .hiko-name.show { opacity: 1; transform: none; }
.hiko-sel { font-size: 1.05rem; color: #d9cdb8; letter-spacing: .12em; }
.hiko-sel .pts { color: #e7b24a; font-size: 1.2rem; margin: 0; }
.hiko-sel .k-toku { color: #ff8f73; }
.hiko-sel .k-nami { color: #9ec1ea; }
.hiko-name { font-size: clamp(1.6rem, 4.5vh, 2.6rem); font-weight: 700; letter-spacing: .3em; color: #fff7ea; }
.hiko-nav { display: flex; gap: .6rem; justify-content: center; padding: 12px 16px calc(16px + var(--safe-b)); }
.hiko-nav button { min-height: 52px; padding: 0 1.4rem; border-radius: 999px; border: 1px solid #5a5047; background: transparent; color: #f3ebdc; font-weight: 700; cursor: pointer; }
.hiko-nav button.go { background: var(--shu); border-color: var(--shu); min-width: 14em; }
.hiko-hint { text-align: center; color: #7d7266; font-size: .78rem; padding-bottom: 6px; }

/* ---------- 検索・成績 ---------- */
.search-form .row-kw { display: flex; gap: 8px; }
.search-form .row-kw input { flex: 1; }
.search-more summary { cursor: pointer; color: var(--ai); font-size: .9rem; margin: .6rem 0; }
.sr-head { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin: 1rem 0 .4rem; flex-wrap: wrap; }
.sr-list { list-style: none; padding: 0; margin: 0; }
.sr-list li { border-bottom: 1px solid var(--line); }
.sr-list a { display: block; padding: .8rem .3rem; text-decoration: none; color: inherit; }
.sr-list a:hover { background: rgba(255, 252, 246, .7); }
.sr-ku { font-family: var(--mincho); font-size: clamp(1.08rem, 4.4vw, 1.22rem); letter-spacing: .04em; text-wrap: balance; }
.sr-ku mark { background: #f3dd9b; color: inherit; border-radius: 2px; }
.sr-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .2rem .8rem; font-size: .86rem; color: var(--ink-2); margin-top: .1rem; }
.sr-author { font-family: var(--mincho); font-weight: 700; color: var(--ink); }
.sr-meta2 { font-size: .8rem; color: var(--ink-3); }
.presets { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.presets button { border: 1px solid var(--line-2); background: transparent; border-radius: 999px; padding: .25em .9em; cursor: pointer; font-size: .85rem; min-height: 34px; }
.presets button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.stats { width: 100%; border-collapse: collapse; font-size: .92rem; white-space: nowrap; }
table.stats th, table.stats td { padding: .55rem .5rem; border-bottom: 1px solid var(--line); text-align: right; }
table.stats th { font-size: .78rem; color: var(--ink-3); font-weight: 600; }
table.stats td.name, table.stats th.name { text-align: left; }
table.stats td.name a { font-family: var(--mincho); font-weight: 700; color: var(--ink); text-decoration: none; }
table.stats td.pt { font-family: var(--mincho); font-weight: 700; font-size: 1.1rem; color: var(--shu-d); }
table.stats td.name, table.stats th.name { position: sticky; left: 0; background: var(--card); z-index: 1; }

/* ---------- 幹事 ---------- */
.member-list { list-style: none; padding: 0; margin: 0; }
.member-list > li { display: flex; align-items: center; gap: .7rem; padding: .7rem 0; border-bottom: 1px dashed var(--line); flex-wrap: wrap; }
.member-list .m-name { font-weight: 600; flex: 1; min-width: 8em; }
.member-list .m-tags { display: flex; gap: .3rem; }
.mtag { font-size: .72rem; padding: 0 .55em; border-radius: 4px; background: var(--paper-2); color: var(--ink-2); font-weight: 700; }
.mtag.admin { background: var(--ink); color: var(--paper); }
.mtag.lock { background: var(--shu-soft); color: var(--shu-d); }
.member-list form { width: 100%; display: grid; grid-template-columns: 5em 1fr; gap: 8px; align-items: center; }
.member-list form .full { grid-column: 1 / -1; }
.add-member { display: grid; grid-template-columns: 6em 1fr 8em; gap: 8px 10px; align-items: end; }
.add-member label { font-size: .82rem; color: var(--ink-2); font-weight: 600; }
.add-member .full { grid-column: 1 / -1; }
@media (max-width: 559px) { .add-member { grid-template-columns: 6em 1fr; } }
.invite { margin-top: 12px; background: var(--paper-2); border-radius: 10px; padding: 12px; }
.invite pre { white-space: pre-wrap; font-family: inherit; margin: 0 0 8px; font-size: .9rem; }
.csv-result { margin-top: 10px; font-size: .9rem; }
.csv-result ul { margin: .3rem 0; padding-left: 1.2em; }
.csv-result .err { color: var(--shu-d); }
.size-opts { display: flex; gap: .5rem; }
.size-opts button { flex: 1; border: 1px solid var(--line-2); background: transparent; border-radius: 10px; min-height: 48px; cursor: pointer; }
.size-opts button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .4rem 0; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 52px; height: 30px; border-radius: 999px; background: var(--line-2); position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked { background: var(--moss); }
.switch input:checked::after { transform: translateX(22px); }
.install-steps { font-size: .9rem; padding-left: 1.2em; margin: .4rem 0; }
.errbox { border-left: 4px solid var(--shu); }

/* トースト */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b)); z-index: 80; width: max-content;
  transform: translate(-50%, 30px); opacity: 0; pointer-events: none;
  background: var(--ink); color: #fbf6ec; padding: .7rem 1.2rem; border-radius: 12px;
  max-width: min(92vw, 520px); font-size: .92rem; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--shu-d); }
@media (max-width: 759px) { .toast { bottom: calc(var(--tab-h) + var(--safe-b) + 14px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* 印刷（清記・結果） */
@media print {
  body { background: #fff; }
  .topbar, .nav, .admin-panel, .selbar, .toolbar, .result-actions, .tabs, .crumb, .cbtn, .stamp, .hint, .proxy-banner, .card.subtle, .toast, #modal-root, .edit-ku { display: none !important; }
  .main { max-width: none; padding: 0; }
  .ku-card { break-inside: avoid; box-shadow: none; border: none; border-bottom: 1px solid #ccc; border-radius: 0; background: #fff !important; padding: 6px 0; }
  .ku-foot { min-height: 0; }
  .author-block { box-shadow: none; break-inside: avoid; }
  .stepper { display: none; }
}
