/* LoopLine 管理画面 - 秘密値を含めない。配信停止中の操作は常に無効表示にする。 */
:root {
  --brand: #675de7;
  --brand-deep: #5148b7;
  --brand-soft: #f1efff;
  --bg: #edf0f3;
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --border: #e8ebf0;
  --border-strong: #dfe3e9;
  --text: #19202f;
  --text-muted: #788292;
  --text-faint: #99a2b0;
  --ok: #1f8a5b;
  --ok-soft: #e2f4ec;
  --warn: #9a6b0f;
  --warn-soft: #fbf0d9;
  --stop: #b3382c;
  --stop-soft: #fbe4e1;
  --idle: #7d8695;
  --idle-soft: #eceff3;
  --shadow: 0 1px 2px rgba(25, 32, 47, .05), 0 10px 30px -20px rgba(25, 32, 47, .35);
  --font: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.7; -webkit-font-smoothing: antialiased; }
button, select, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ===== ログイン ===== */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 34px 32px; box-shadow: var(--shadow); }
.login-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 26px; }
.login-brand span { width: 40px; height: 40px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border-strong); display: grid; place-items: center; flex: none; }
.login-brand b { font-size: 18px; line-height: 1.2; }
.login-brand b small { display: block; font-size: 10.5px; font-weight: 400; color: var(--text-faint); }
.login-card h1 { font-size: 19px; margin: 0 0 6px; }
.login-card .lede { color: var(--text-muted); font-size: 13.5px; margin: 0 0 22px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 5px; }
.field input { width: 100%; padding: 10px 13px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-2); }
.field input:focus { background: var(--surface); border-color: var(--brand); }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }

/* ===== 共通部品 ===== */
.btn { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 7px 14px; font-size: 13.5px; cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-deep); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.btn.primary:hover:not(:disabled) { background: var(--brand-deep); color: #fff; }
.btn.block { width: 100%; padding: 11px; font-size: 15px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.msg { border-radius: 8px; padding: 11px 14px; font-size: 13.5px; margin-bottom: 16px; border: 1px solid; }
.msg-error { background: var(--stop-soft); border-color: var(--stop); color: var(--stop); }
.msg-info { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-deep); }

.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: 99px; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-ok { background: var(--ok-soft); color: var(--ok); }
.b-warn { background: var(--warn-soft); color: var(--warn); }
.b-stop { background: var(--stop-soft); color: var(--stop); }
.b-idle { background: var(--idle-soft); color: var(--idle); }

.strip { display: flex; gap: 10px; align-items: flex-start; border-radius: 9px; padding: 12px 15px; margin-bottom: 20px; font-size: 13.5px; border: 1px solid; }
.strip p { margin: 0; }
.strip strong { display: block; }
.s-stop { background: var(--stop-soft); border-color: var(--stop); color: var(--stop); }
.s-idle { background: var(--idle-soft); border-color: var(--border-strong); color: var(--text-muted); }

/* ===== アプリ枠 ===== */
.app { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; background: var(--surface); }

.side { border-right: 1px solid var(--border); background: var(--surface-2); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 9px; padding: 0 8px 16px; }
.brand i { width: 30px; height: 30px; border-radius: 8px; background: #fff; border: 1px solid var(--border-strong); display: grid; place-items: center; font-style: normal; flex: none; }
.brand b { font-size: 16px; line-height: 1.15; }
.brand b small { display: block; font-size: 10px; font-weight: 400; color: var(--text-faint); }
.ws { display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 10px; margin-bottom: 14px; }
.ws i { width: 24px; height: 24px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 700; flex: none; }
.ws div { flex: 1; min-width: 0; }
.ws strong { display: block; font-size: 13px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws small { color: var(--text-faint); font-size: 11px; }
.side-label { font-size: 10.5px; letter-spacing: .12em; color: var(--text-faint); padding: 10px 8px 4px; }
.navitem { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; border-radius: 7px; padding: 7px 9px; cursor: pointer; color: var(--text-muted); font-size: 13.5px; }
.navitem:hover { background: var(--surface); color: var(--text); }
.navitem[aria-current="true"] { background: var(--brand-soft); color: var(--brand-deep); font-weight: 700; }
.navitem i { font-style: normal; width: 18px; text-align: center; font-size: 14px; }
.navitem .dot { margin-left: auto; width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot-ok { background: var(--ok); } .dot-warn { background: var(--warn); } .dot-stop { background: var(--stop); } .dot-idle { background: var(--idle); }
.side-foot { margin-top: auto; border-top: 1px solid var(--border); padding-top: 10px; }
.me { display: flex; align-items: center; gap: 9px; padding: 9px 8px 0; }
.me i { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-deep); display: grid; place-items: center; font-style: normal; font-size: 12px; font-weight: 700; flex: none; }
.me div { flex: 1; min-width: 0; }
.me strong { display: block; font-size: 12.5px; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me small { color: var(--text-faint); font-size: 11px; }

.top { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 12px 24px; border-bottom: 1px solid var(--border); }
.acct { display: flex; align-items: center; gap: 8px; background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 8px; padding: 5px 10px; }
.acct .led { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.acct select { background: none; border: 0; font-size: 13.5px; font-weight: 600; cursor: pointer; max-width: 300px; }
.top-right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

.screen { padding: 24px; }
.head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; margin-bottom: 20px; }
.head h1 { font-size: 21px; margin: 0 0 4px; }
.head p { margin: 0; color: var(--text-muted); font-size: 13.5px; max-width: 62ch; }
.head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 20px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi p { margin: 0; font-size: 12.5px; color: var(--text-muted); }
.kpi strong { display: block; font-size: 26px; line-height: 1.3; font-variant-numeric: tabular-nums; }
.kpi small { font-size: 11.5px; color: var(--text-faint); }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); overflow: hidden; margin-bottom: 14px; }
.panel-h { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.panel-h h2 { margin: 0; font-size: 14.5px; }
.panel-h small { color: var(--text-faint); font-size: 12px; }
.panel-h .r { margin-left: auto; }
.panel-b { padding: 14px 16px; }

.scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 9px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; letter-spacing: .06em; color: var(--text-muted); background: var(--surface-2); font-weight: 700; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
.n { font-variant-numeric: tabular-nums; }
.tag { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand-deep); margin: 1px 3px 1px 0; }
.who { display: flex; align-items: center; gap: 8px; }
.who i { width: 26px; height: 26px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border-strong); display: grid; place-items: center; font-style: normal; font-size: 11px; color: var(--text-muted); flex: none; }

/* ===== 受信箱 ===== */
.talk { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 460px; }
.talk-list { border-right: 1px solid var(--border); overflow-y: auto; max-height: 560px; }
.talk-item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--border); background: none; padding: 11px 14px; cursor: pointer; }
.talk-item:hover { background: var(--surface-2); }
.talk-item[aria-current="true"] { background: var(--brand-soft); }
.talk-item strong { display: block; font-size: 13px; }
.talk-item p { margin: 0; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.talk-body { padding: 16px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.talk-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; max-height: 420px; }
.bub { max-width: 74%; padding: 9px 13px; border-radius: 13px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; }
.bub.them { background: var(--surface-2); border: 1px solid var(--border); border-top-left-radius: 4px; align-self: flex-start; }
.bub.us { background: var(--brand); color: #fff; border-top-right-radius: 4px; align-self: flex-end; }
.bub time { display: block; font-size: 10.5px; opacity: .7; margin-top: 3px; }
.composer { display: flex; gap: 8px; padding-top: 12px; border-top: 1px solid var(--border); align-items: flex-start; }
.composer textarea { flex: 1; border: 1px solid var(--border-strong); border-radius: 8px; padding: 8px 12px; background: var(--surface-2); resize: vertical; min-height: 42px; font-size: 13.5px; }

/* ===== 友だち詳細 ===== */
.timeline { display: flex; flex-direction: column; }
.tl { display: flex; gap: 11px; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.tl:last-child { border-bottom: 0; }
.tl i { width: 26px; height: 26px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--border-strong); display: grid; place-items: center; font-style: normal; font-size: 12px; color: var(--text-muted); flex: none; }
.tl div { flex: 1; min-width: 0; }
.tl strong { display: block; font-size: 13px; }
.tl p { margin: 0; font-size: 12.5px; color: var(--text-muted); word-break: break-word; }
.tl time { font-size: 11.5px; color: var(--text-faint); white-space: nowrap; }

/* ===== 入力フォーム（タグ管理など） ===== */
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .field { flex: 1; min-width: 190px; margin-bottom: 12px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.field input[type="color"] { height: 42px; padding: 3px; cursor: pointer; }
.btn.small { padding: 4px 11px; font-size: 12.5px; }
.btn.danger { color: var(--stop); border-color: var(--stop); }
.btn.danger:hover:not(:disabled) { background: var(--stop-soft); color: var(--stop); border-color: var(--stop); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { display: inline-flex; align-items: center; gap: 8px; }
.swatch i { width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--border-strong); flex: none; font-style: normal; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--text-faint); }
.field textarea { width: 100%; border: 1px solid var(--border-strong); border-radius: 8px; padding: 9px 12px; background: var(--surface-2); resize: vertical; min-height: 78px; font-size: 14px; line-height: 1.7; }
.field textarea:focus { background: var(--surface); border-color: var(--brand); }
.msg-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.msg-head label { margin: 0; }
.msg-head button { margin-left: auto; }
.check { display: flex; gap: 10px; align-items: flex-start; background: var(--warn-soft); border: 1px solid var(--warn); border-radius: 9px; padding: 12px 15px; margin-bottom: 16px; cursor: pointer; }
.check input { margin: 4px 0 0; width: 17px; height: 17px; flex: none; cursor: pointer; }
.check span { font-size: 13.5px; color: var(--warn); }
.check strong { display: block; }

/* ===== 初期パスワードの1度きり表示 ===== */
.secret { background: var(--warn-soft); border: 2px solid var(--warn); border-radius: 10px; padding: 16px 19px; margin-bottom: 16px; }
.secret h3 { margin: 0 0 8px; font-size: 15px; color: var(--warn); }
.secret p { margin: 0 0 11px; font-size: 13.5px; color: var(--warn); }
.secret .value { display: block; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 7px; padding: 12px 14px; font-family: ui-monospace, Consolas, monospace; font-size: 17px; word-break: break-all; user-select: all; margin-bottom: 11px; color: var(--text); }
.role-note { font-size: 12px; color: var(--text-faint); }

.empty { text-align: center; padding: 42px 20px; color: var(--text-muted); }
.empty i { display: block; font-style: normal; font-size: 30px; opacity: .3; margin-bottom: 8px; }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.empty p { margin: 0 auto; max-width: 46ch; font-size: 13.5px; }

.loading { text-align: center; padding: 34px; color: var(--text-faint); font-size: 13.5px; }

@media (max-width: 940px) {
  .app { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); padding: 12px; }
  .brand, .ws, .side-label, .side-foot { width: 100%; }
  .side-foot { margin-top: 8px; }
  .navitem { width: auto; }
  .talk { grid-template-columns: 1fr; }
  .talk-list { border-right: 0; border-bottom: 1px solid var(--border); max-height: 200px; }
}
