/* link-matome 管理画面共通スタイル — 白基調・ゴシック・大きめ文字・装飾最小 */
:root {
  --plane: #f5f5f3;
  --surface: #ffffff;
  --ink: #1c1c1c;
  --ink-2: #55544f;
  --muted: #8a8984;
  --line: #e3e2dd;
  --line-strong: #c9c8c1;
  --accent: #1c1c1c;
  --link: #1f5fbf;
  --danger: #c43333;
  --good: #1a7f37;
  --series-1: #2a78d6; /* 表示回数 */
  --series-2: #eb6834; /* クリック */
  --radius: 12px;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--plane); color: var(--ink); font-family: var(--font); font-size: 15px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }
[hidden] { display: none !important; }
.boot { padding: 40px 20px; color: var(--muted); text-align: center; }

/* ---------- ボタン・入力 ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 700; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: #f0f0ed; text-decoration: none; }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #333; }
.btn-danger { color: var(--danger); border-color: #e6c3c3; }
.btn-danger:hover { background: #fbf0f0; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { min-height: 34px; padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: #efefec; color: var(--ink); }
.icon-btn svg { width: 20px; height: 20px; }

.field { display: block; margin: 0 0 16px; }
.label { display: block; font-size: 13px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.hint { display: block; font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.input, .textarea, .select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; color: var(--ink); font: inherit; font-size: 15px; }
.textarea { min-height: 96px; resize: vertical; line-height: 1.6; }
.input:focus, .textarea:focus, .select:focus { outline: 2px solid var(--ink); outline-offset: -1px; border-color: var(--ink); }
.input-group { display: flex; align-items: stretch; }
.input-group .prefix { display: flex; align-items: center; padding: 0 10px; border: 1px solid var(--line-strong); border-right: 0; border-radius: 10px 0 0 10px; background: #f3f3f0; color: var(--ink-2); font-size: 13px; white-space: nowrap; max-width: 55%; overflow: hidden; text-overflow: ellipsis; }
.input-group .input { border-radius: 0 10px 10px 0; min-width: 0; }
.form-error { color: var(--danger); font-size: 13.5px; margin: 0 0 12px; }
.form-ok { color: var(--good); font-size: 13.5px; margin: 0 0 12px; }

/* トグルスイッチ */
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; color: var(--ink-2); user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: #cfcec8; position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 2px solid var(--link); outline-offset: 2px; }

/* ---------- レイアウト ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top, 0px); }
.topbar-in { max-width: 1180px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 800; font-size: 16px; color: var(--ink); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.topbar .spacer { flex: 1; }
.who { font-size: 13px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.acting-bar { background: #1c1c1c; color: #fff; font-size: 13.5px; }
.acting-bar .in { max-width: 1180px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.acting-bar button { background: #fff; color: #1c1c1c; border: 0; border-radius: 8px; padding: 5px 12px; font-weight: 700; cursor: pointer; font-size: 13px; }

.container { max-width: 1180px; margin: 0 auto; padding: 20px 16px 80px; }
.narrow { max-width: 640px; }
.page-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin: 4px 0 16px; }
.page-head h1 { font-size: 22px; margin: 0; line-height: 1.3; word-break: break-word; }
.page-head .grow { flex: 1; min-width: 200px; }
.back { display: inline-block; font-size: 13.5px; margin-bottom: 6px; color: var(--ink-2); }

.urlbox { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13.5px; color: var(--ink-2); margin-top: 4px; }
.urlbox code { font-family: inherit; color: var(--ink); background: #efefeb; padding: 3px 8px; border-radius: 6px; word-break: break-all; }
.badge { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--ink-2); background: #fff; white-space: nowrap; }
.badge-on { border-color: #b9dcc4; color: var(--good); background: #f1f8f3; }
.badge-off { border-color: #e6c3c3; color: var(--danger); background: #fbf2f2; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 0 0 20px; overflow-x: auto; }
.tab { appearance: none; border: 0; background: none; padding: 12px 16px; font-size: 15px; font-weight: 700; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.card h2 { font-size: 16px; margin: 0 0 14px; }
.card h2 small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
.card-sub { font-size: 13px; color: var(--muted); margin: -8px 0 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 180px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.edit-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.preview-col { position: sticky; top: 76px; }
.phone { width: 360px; height: 700px; margin: 0 auto; border: 10px solid #1c1c1c; border-radius: 40px; overflow: hidden; background: #fff; }
.phone iframe { width: 100%; height: 100%; border: 0; display: block; }
.preview-note { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 10px; }
.mobile-preview-btn { display: none; }

/* ---------- アイコン画像 ---------- */
.avatar-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.avatar { width: 80px; height: 80px; border-radius: 50%; object-fit: cover; background: #ecebe7; display: grid; place-items: center; font-size: 28px; font-weight: 700; color: var(--muted); flex: none; }

/* ---------- リンク一覧 ---------- */
.add-bar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.links { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.link-item { display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 10px 4px; }
.link-item.is-off { background: #fafaf8; }
.link-item.is-off .li-title, .link-item.is-off .li-url { color: var(--muted); }
.link-item.dragging { opacity: .5; }
.link-item.drop-before { box-shadow: 0 -3px 0 var(--ink); }
.link-item.drop-after { box-shadow: 0 3px 0 var(--ink); }
.handle { cursor: grab; touch-action: none; color: var(--muted); }
.li-body { flex: 1; min-width: 0; }
.li-title { font-weight: 700; font-size: 15px; word-break: break-word; }
.li-url { font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-kind { font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .04em; }
.li-meta { font-size: 12px; color: var(--muted); white-space: nowrap; }
.li-actions { display: flex; align-items: center; gap: 2px; flex: none; }
.link-edit { border: 1px solid var(--ink); border-radius: 12px; padding: 14px; background: #fff; }
.empty { text-align: center; padding: 28px 16px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: 12px; }

.sns-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 14px; }
.sns-label { display: flex; align-items: center; gap: 6px; }
.sns-label svg { width: 16px; height: 16px; }

.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.theme-opt { border: 2px solid var(--line); border-radius: 12px; padding: 10px 8px 8px; cursor: pointer; background: #fff; text-align: center; font-size: 12.5px; font-weight: 700; color: var(--ink-2); }
.theme-opt[aria-checked="true"] { border-color: var(--ink); color: var(--ink); }
.theme-swatch { height: 56px; border-radius: 8px; display: flex; flex-direction: column; justify-content: center; gap: 5px; padding: 0 10px; margin-bottom: 6px; }
.theme-swatch i { display: block; height: 11px; border-radius: 4px; }

/* ---------- 解析 ---------- */
.filter-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.seg { display: inline-flex; background: #ebebe7; border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 700; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.range-label { font-size: 13px; color: var(--muted); }
.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .k-label { font-size: 13px; color: var(--ink-2); font-weight: 700; }
.kpi .k-value { font-size: 30px; font-weight: 700; line-height: 1.2; margin-top: 4px; }
.kpi .k-delta { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi .k-help { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.stats-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.stats-grid .card { margin-bottom: 0; }
.loading-dim { opacity: .45; transition: opacity .15s; }

.chart-wrap { position: relative; }
.chart-legend { display: flex; gap: 16px; flex-wrap: wrap; font-size: 13px; color: var(--ink-2); margin-bottom: 8px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid-line { stroke: #e7e6e0; stroke-width: 1; }
.chart .axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tooltip { position: absolute; pointer-events: none; background: #fff; border: 1px solid var(--line-strong); border-radius: 10px; padding: 8px 12px; font-size: 12.5px; box-shadow: 0 4px 16px rgba(0,0,0,.08); white-space: nowrap; z-index: 5; }
.tooltip .t-day { color: var(--muted); margin-bottom: 4px; }
.tooltip .t-row { display: flex; align-items: center; gap: 8px; }
.tooltip .t-row i { width: 12px; height: 3px; border-radius: 2px; display: inline-block; }
.tooltip .t-row b { font-size: 14px; min-width: 28px; text-align: right; }
.table-toggle { margin-top: 10px; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table th { font-size: 12.5px; color: var(--ink-2); font-weight: 700; white-space: nowrap; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.bar-cell { min-width: 90px; width: 30%; }
.hbar { height: 10px; background: #eeeeea; border-radius: 0 4px 4px 0; overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--series-2); border-radius: 0 4px 4px 0; }
.hbar.views i { background: var(--series-1); }
.t-title { font-weight: 700; word-break: break-word; }
.t-url { font-size: 12px; color: var(--muted); word-break: break-all; }

/* ---------- 一覧（ページ・アカウント） ---------- */
.list { display: flex; flex-direction: column; gap: 10px; }
.list-item { display: flex; align-items: center; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; flex-wrap: wrap; }
.list-item .grow { flex: 1; min-width: 180px; }
.list-item .li-stats { display: flex; gap: 18px; font-size: 13px; color: var(--ink-2); }
.list-item .li-stats b { display: block; font-size: 18px; color: var(--ink); }

/* ---------- モーダル・トースト ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; padding: 22px; }
.modal h3 { margin: 0 0 14px; font-size: 18px; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 18px; }
.modal.wide { max-width: 440px; padding: 12px; }
.handoff { white-space: pre-wrap; background: #f5f5f2; border: 1px solid var(--line); border-radius: 10px; padding: 12px; font-size: 14px; line-height: 1.8; word-break: break-all; }
.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: #1c1c1c; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 60; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.2); }
.toast.error { background: var(--danger); }
.qr-box { display: grid; place-items: center; padding: 10px; }
.qr-box img { width: 240px; height: 240px; image-rendering: pixelated; }

/* ---------- ログイン ---------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 400px; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 32px 24px; }
.auth-title { font-size: 22px; margin: 0; text-align: center; }
.auth-sub { text-align: center; color: var(--ink-2); margin: 4px 0 24px; font-size: 14px; }
.auth-note { font-size: 12.5px; color: var(--muted); margin: 18px 0 0; text-align: center; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 1000px) {
  .edit-grid { grid-template-columns: minmax(0, 1fr); }
  .preview-col { display: none; }
  .mobile-preview-btn { display: inline-flex; }
}
@media (max-width: 760px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats-grid { grid-template-columns: minmax(0, 1fr); }
  .sns-grid { grid-template-columns: minmax(0, 1fr); }
  .page-head h1 { font-size: 19px; }
  .card { padding: 16px; }
  .kpi .k-value { font-size: 26px; }
  .who { display: none; }
}
@media (max-width: 420px) {
  .phone { width: 100%; height: 72vh; border-width: 6px; border-radius: 24px; }
  .li-meta { display: none; }
}
