/* Lumi ダッシュボード — 公式サイトと同じ配色(夜空の藍 + 琥珀)。暗色が基準、明色は OS設定 / data-theme で切替 */
:root {
  --bg: #14112e; --bg2: #1b1740; --card: #1e1a48; --card2: #26215a; --code: #0e0b26;
  --fg: #ece9ff; --mut: #aaa5d6; --line: #322d68;
  --accent: #ffb347; --accent-soft: rgba(255,179,71,.14);
  --brand: #8f83ff; --btn-bg: #ffb347; --btn-fg: #25180a;
  --ok: #4cd18a; --warn: #ffcf5c; --err: #ff7a85; --ok-soft: rgba(76,209,138,.14); --warn-soft: rgba(255,207,92,.14); --err-soft: rgba(255,122,133,.14);
  --head: "Zen Maru Gothic","Hiragino Maru Gothic ProN","Yu Gothic",system-ui,sans-serif;
  --body: "Zen Kaku Gothic New","Hiragino Sans","Yu Gothic",system-ui,sans-serif;
  --shadow: 0 10px 30px rgba(0,0,0,.28);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f6f5ff; --bg2: #eeecff; --card: #ffffff; --card2: #f3f1ff; --code: #f1efff;
    --fg: #1d1a45; --mut: #5b5885; --line: #dcd8f5;
    --accent: #b85f00; --accent-soft: rgba(184,95,0,.1);
    --brand: #5b4cf0; --btn-bg: #3b2fd1; --btn-fg: #fff;
    --ok: #12804a; --warn: #8a5a00; --err: #c0303d; --ok-soft: rgba(18,128,74,.1); --warn-soft: rgba(138,90,0,.1); --err-soft: rgba(192,48,61,.1);
    --shadow: 0 10px 30px rgba(40,30,120,.12); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f6f5ff; --bg2: #eeecff; --card: #ffffff; --card2: #f3f1ff; --code: #f1efff;
  --fg: #1d1a45; --mut: #5b5885; --line: #dcd8f5;
  --accent: #b85f00; --accent-soft: rgba(184,95,0,.1);
  --brand: #5b4cf0; --btn-bg: #3b2fd1; --btn-fg: #fff;
  --ok: #12804a; --warn: #8a5a00; --err: #c0303d; --ok-soft: rgba(18,128,74,.1); --warn-soft: rgba(138,90,0,.1); --err-soft: rgba(192,48,61,.1);
  --shadow: 0 10px 30px rgba(40,30,120,.12); color-scheme: light;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 400 15px/1.75 var(--body); -webkit-text-size-adjust: 100%; }
h1, h2, h3 { font-family: var(--head); line-height: 1.35; margin: 0; text-wrap: balance; }
a { color: var(--accent); }
p { margin: 0 0 10px; }
.mut { color: var(--mut); }
.small { font-size: 13px; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.ic { width: 18px; height: 18px; flex: none; }
.grow { flex: 1; }

/* 上部バー */
.bar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; min-height: 58px;
  padding: 0 max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--fg); text-decoration: none; font: 900 19px var(--head); }
.brand img { width: 30px; height: 30px; border-radius: 9px; }
.bar-btn { gap: 6px; }
.bar-btn .ic { width: 16px; height: 16px; }
.user { font-size: 13px; color: var(--mut); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: transparent; color: var(--mut); cursor: pointer; }
.icon-btn:hover { color: var(--fg); border-color: var(--accent); }

/* ボタン・入力 */
button, input, select, textarea { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 0 18px; border-radius: 999px;
  background: var(--btn-bg); color: var(--btn-fg); border: 2px solid var(--btn-bg); font-weight: 700; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn.ghost { background: transparent; color: var(--fg); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--accent); }
.btn.danger { background: transparent; color: var(--err); border-color: color-mix(in srgb, var(--err) 50%, transparent); }
.btn.sm { min-height: 32px; padding: 0 13px; font-size: 13px; }
.btn.icon { padding: 0; width: 34px; min-height: 34px; }
input[type=text], input[type=password], input[type=number], input[type=date], select, textarea { width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
select option:disabled { color: var(--mut); }
label.f { display: block; font-size: 13px; font-weight: 700; color: var(--mut); margin-bottom: 6px; }
.field { margin-bottom: 16px; min-width: 0; }
.hint { font-size: 12.5px; color: var(--mut); margin: 6px 0 0; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 16px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input[type=number] { width: 130px; }

/* スイッチ */
.sw { display: flex; align-items: flex-start; gap: 12px; cursor: pointer; padding: 6px 0; }
.sw input { position: absolute; opacity: 0; }
.sw i { flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--line); position: relative; margin-top: 2px; transition: background .15s; }
.sw i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; }
.sw input:checked + i { background: var(--accent); }
.sw input:checked + i::after { transform: translateX(16px); }
.sw input:focus-visible + i { outline: 3px solid var(--accent); outline-offset: 2px; }
.sw b { display: block; font-weight: 700; line-height: 1.4; }
.sw small { display: block; color: var(--mut); font-size: 12.5px; line-height: 1.5; }

/* ログイン */
.login { max-width: 420px; margin: 12vh auto 0; padding: 0 20px; text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 20px; box-shadow: var(--shadow); }
.login h1 { font-size: 28px; margin: 18px 0 8px; font-weight: 900; }
.login p { color: var(--mut); margin-bottom: 22px; }

/* サーバー一覧 */
.wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 28px max(16px, env(safe-area-inset-right)) 70px max(16px, env(safe-area-inset-left)); }
.h-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.h-row h1 { font-size: 26px; font-weight: 900; }
.sec-t { font: 700 13px var(--body); letter-spacing: .12em; color: var(--mut); margin: 28px 0 12px; }
.guilds { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.gcard { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 16px; background: var(--card); border: 1px solid var(--line); min-width: 0; }
.gcard.link { text-decoration: none; color: inherit; transition: transform .12s, border-color .12s; }
.gcard.link:hover { transform: translateY(-2px); border-color: var(--accent); }
.gicon { width: 48px; height: 48px; border-radius: 15px; flex: none; background: var(--card2); display: grid; place-items: center; font: 900 18px var(--head); color: var(--accent); overflow: hidden; }
.gicon img { width: 100%; height: 100%; object-fit: cover; }
.gmeta { min-width: 0; flex: 1; }
.gname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { display: inline-block; font-size: 11.5px; font-weight: 700; padding: 1px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.badge.mut { background: transparent; color: var(--mut); border-color: var(--line); }

/* サーバー画面: サイドバー + 本文 */
.shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 0; max-width: 1180px; margin: 0 auto; min-height: calc(100vh - 59px); }
.side { position: sticky; top: 59px; align-self: start; padding: 22px 14px 30px max(16px, env(safe-area-inset-left)); max-height: calc(100vh - 59px); overflow: auto; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--mut); text-decoration: none; margin-bottom: 14px; }
.back:hover { color: var(--fg); }
.gh { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; min-width: 0; }
.gh .gicon { width: 44px; height: 44px; border-radius: 14px; }
.gh .gname { font-family: var(--head); font-weight: 700; }
.nav-g { font: 700 11.5px var(--body); letter-spacing: .14em; color: var(--mut); margin: 18px 0 6px 10px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 11px; color: var(--mut); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--card); color: var(--fg); }
.nav a[aria-current] { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.main { min-width: 0; padding: 26px max(16px, env(safe-area-inset-right)) 80px 22px; }
.page { max-width: 820px; }
.ph { margin-bottom: 20px; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ph > div:first-child { flex: 1 1 320px; min-width: 0; }
.ph h1 { font-size: 26px; font-weight: 900; }
.ph p { margin: 4px 0 0; color: var(--mut); }
.acts { display: flex; gap: 8px; flex-wrap: wrap; flex: none; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 20px; margin-bottom: 16px; }
.card > h2 { font-size: 17px; font-weight: 700; margin-bottom: 4px; }
.card > .sub { color: var(--mut); font-size: 13.5px; margin-bottom: 14px; }
.card.flush { padding: 0; overflow: hidden; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); background: var(--card2); }
.card-h h2 { font-size: 16px; font-weight: 700; }

/* 概要 */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; }
.tile .k { font-size: 12.5px; color: var(--mut); font-weight: 700; }
.tile .v { font: 900 28px var(--head); margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile .u { font-size: 13px; font-weight: 500; color: var(--mut); margin-left: 3px; }
.todo { list-style: none; margin: 0; padding: 0; }
.todo li { display: flex; align-items: flex-start; gap: 12px; padding: 13px 0; border-top: 1px solid var(--line); }
.todo li:first-child { border-top: 0; padding-top: 2px; }
.todo .mark { width: 24px; height: 24px; border-radius: 50%; flex: none; display: grid; place-items: center; border: 2px solid var(--line); color: transparent; margin-top: 1px; }
.todo .done .mark { background: var(--ok); border-color: var(--ok); color: #08301b; }
.todo .warn .mark { border-color: var(--warn); color: var(--warn); background: var(--warn-soft); }
.todo b { display: block; line-height: 1.4; }
.todo .grow { min-width: 0; }

/* ルール */
.rg + .rg { margin-top: 16px; }
.rule { display: flex; align-items: center; gap: 14px; padding: 13px 18px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.rule:first-of-type { border-top: 0; }
.rule .thr { font: 900 18px var(--head); min-width: 92px; font-variant-numeric: tabular-nums; }
.rule .thr small { font: 500 12.5px var(--body); color: var(--mut); margin-left: 2px; }
.rule .arrow { color: var(--mut); }
.rule .acts { margin-left: auto; }
.rule .rolebox { flex: 1; min-width: 160px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.role { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; padding: 3px 12px 3px 10px; border-radius: 999px; background: var(--card2); border: 1px solid var(--line); }
.dot { width: 11px; height: 11px; border-radius: 50%; flex: none; background: var(--mut); }
.empty { text-align: center; padding: 40px 20px; }
.empty .ic { width: 38px; height: 38px; color: var(--accent); margin-bottom: 8px; }
.empty h2 { font-size: 18px; margin-bottom: 6px; }
.empty p { color: var(--mut); max-width: 28em; margin: 0 auto 16px; }

/* ランキング */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; margin-bottom: 16px; }
.seg button { border: 0; background: transparent; color: var(--mut); padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 13.5px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--btn-fg); }
.lb { list-style: none; margin: 0; padding: 0; }
.lb li { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 11px 18px; border-top: 1px solid var(--line); }
.lb li:first-child { border-top: 0; }
.lb .rk { font: 900 17px var(--head); text-align: center; color: var(--mut); }
.lb .rk.top { color: var(--accent); }
.lb .nm { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .val { font: 700 15px var(--body); font-variant-numeric: tabular-nums; }
.lb .barw { grid-column: 2 / 4; height: 5px; border-radius: 4px; background: var(--line); overflow: hidden; }
.lb .barw i { display: block; height: 100%; border-radius: 4px; background: var(--accent); }

/* 進捗バー */
.prog { height: 10px; background: var(--line); border-radius: 6px; overflow: hidden; margin: 12px 0 8px; }
.prog i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .5s; }

/* モーダル */
.mbg { position: fixed; inset: 0; z-index: 50; background: rgba(8,6,26,.62); display: grid; place-items: center; padding: 16px; animation: fade .12s; }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px 0; }
.modal header h2 { font-size: 19px; font-weight: 900; }
.modal .mb { padding: 16px 22px 6px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 22px 20px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* トースト */
.toast { position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; z-index: 60;
  padding: 10px 18px; border-radius: 12px; background: var(--fg); color: var(--bg); font-weight: 700; font-size: 14px; max-width: calc(100vw - 32px); transition: all .2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: var(--err); color: #fff; }
.skeleton { height: 120px; border-radius: 16px; background: linear-gradient(90deg, var(--card), var(--card2), var(--card)); background-size: 200% 100%; animation: sh 1.2s infinite; }
@keyframes sh { to { background-position: -200% 0; } }

/* アクセス権限 */
.rolegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.rolepick { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg2); cursor: pointer; min-width: 0; }
.rolepick input { position: absolute; opacity: 0; }
.rolepick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.rolepick:has(input:focus-visible) { outline: 3px solid var(--accent); }
.rolepick:has(input:disabled) { opacity: .6; cursor: default; }
.rolepick span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.rolepick:has(input:checked) span.t { font-weight: 700; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: static; max-height: none; padding: 16px max(16px, env(safe-area-inset-right)) 4px max(16px, env(safe-area-inset-left)); }
  .gh { margin-bottom: 12px; }
  .nav-g { display: none; }
  .nav { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 8px; scrollbar-width: none; margin: 0 -2px; }
  .nav a { flex: none; padding: 8px 14px; border: 1px solid var(--line); border-radius: 999px; }
  .nav a[aria-current] { border-color: var(--accent); }
  .main { padding: 14px max(16px, env(safe-area-inset-right)) 70px max(16px, env(safe-area-inset-left)); }
  .grid2 { grid-template-columns: minmax(0, 1fr); }
  .user { display: none; }
  .bar-btn { padding: 0; width: 34px; }
  .bar-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } /* 画面が狭いときはアイコンだけ(読み上げ用の文字は残す) */
  .rule .thr { min-width: 0; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* 分布 */
.dr { display: grid; grid-template-columns: 112px minmax(0, 1fr) 92px; gap: 4px 12px; align-items: center; padding: 7px 0; }
.dr .l { font-size: 13.5px; color: var(--mut); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dr .b { height: 20px; background: var(--card2); border-radius: 7px; overflow: hidden; }
.dr .b i { display: block; height: 100%; min-width: 2px; background: var(--accent); border-radius: 7px; }
.dr .b.alt i { background: var(--brand); }
.dr .n { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.dr .n small { color: var(--mut); font-weight: 500; margin-left: 4px; }
.dr.zero .b i { display: none; }
.dr.zero .n { color: var(--mut); font-weight: 500; }
.dr .roleline { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
@media (max-width: 520px) { .dr { grid-template-columns: 84px minmax(0, 1fr) 78px; gap: 4px 8px; } }

/* ===== 検索できるプルダウン(picker.js) ===== */
.sx { position: relative; }
.sx-btn { width: 100%; min-height: 42px; padding: 8px 36px 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); text-align: left; cursor: pointer; position: relative; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-btn::after { content: ''; position: absolute; right: 14px; top: 50%; width: 7px; height: 7px; margin-top: -6px; border-right: 2px solid var(--mut); border-bottom: 2px solid var(--mut); transform: rotate(45deg); }
.sx-btn.sx-blank { color: var(--mut); }
.sx-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.sx-panel { position: fixed; z-index: 9999; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 8px; max-width: calc(100vw - 16px); }
.sx-panel[hidden] { display: none; }
.sx-search { margin-bottom: 6px; }
.sx-list { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow: auto; overscroll-behavior: contain; }
.sx-opt { padding: 8px 10px; border-radius: 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-opt:hover, .sx-opt.sx-active { background: var(--accent-soft); }
.sx-opt[aria-disabled="true"] { color: var(--mut); cursor: not-allowed; opacity: .6; }
.sx-opt[hidden], .sx-group[hidden] { display: none; }
.sx-group { padding: 8px 10px 4px; font-size: 12px; font-weight: 700; color: var(--mut); }
.sx-empty { padding: 10px; color: var(--mut); font-size: 14px; }

/* ===== 株の出来事(1行ずつ) ===== */
.ev-row { display: grid; grid-template-columns: 48px minmax(0, 1fr) 84px 150px 84px 40px; gap: 8px; align-items: center; padding: 6px 14px; border-bottom: 1px solid var(--line); }
.ev-row:last-child { border-bottom: 0; }
.ev-row input, .ev-row select { min-height: 36px; padding: 4px 8px; }
.ev-head { font-size: 12px; font-weight: 700; color: var(--mut); }
@media (max-width: 720px) { .ev-row { grid-template-columns: 48px minmax(0, 1fr) 70px 40px; } .ev-row .ev-co, .ev-row .ev-w { grid-column: 2 / 4; } .ev-head { display: none; } }
