/* ===== MEO運用ツール スタイル（ライトテーマ・社内ツール） ===== */

:root {
  --bg: #f5f4f1;
  --surface: #ffffff;
  --ink: #202429;
  --ink-2: #3c4148;
  --muted: #6b7280;
  --line: #e6e3dd;
  --line-2: #efece7;
  --accent: #216b66;        /* 沿岸のティール（GONE house＝海辺の由来） */
  --accent-ink: #16504b;
  --accent-weak: #e5efee;
  --up: #2f7d4f;
  --down: #b5561f;
  --draft: #8a8f98;
  --used: #2f6f9e;
  --done: #2f7d4f;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 26, 33, 0.05), 0 1px 3px rgba(20, 26, 33, 0.04);
  --maxw: 1040px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
    "Hiragino Sans", "Noto Sans JP", "Yu Gothic", Meiryo, sans-serif;
  font-size: 15px;
  line-height: 1.75;
  letter-spacing: 0.01em;
}

h1, h2, h3 { line-height: 1.4; margin: 0; font-weight: 700; letter-spacing: 0.02em; }
h1 { font-size: 1.5rem; }
p { margin: 0 0 0.4rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.ta-c { text-align: center; }
.ta-r { text-align: right; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---- 共通フォーカス（アクセシビリティ・全インタラクティブ要素） ---- */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ===== トップバー ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0.6rem 1.25rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: inline-flex; align-items: center; gap: 0.5rem; color: var(--ink); font-weight: 700; }
.brand:hover { text-decoration: none; }
.brand-mark {
  background: var(--accent); color: #fff;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em;
  padding: 0.2rem 0.42rem; border-radius: 6px;
}
.brand-text { font-size: 0.95rem; }

.client-switch select {
  font-size: 0.9rem; padding: 0.35rem 1.8rem 0.35rem 0.6rem;
  border: 1px solid var(--line); border-radius: 8px; background: var(--surface);
  color: var(--ink); cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%236b7280' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.6rem center;
}
.mainnav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-left: auto; }
.mainnav a {
  color: var(--ink-2); padding: 0.4rem 0.7rem; border-radius: 8px; font-size: 0.9rem;
}
.mainnav a:hover { background: var(--line-2); text-decoration: none; }
.mainnav a.active { background: var(--accent-weak); color: var(--accent-ink); font-weight: 700; }
.logout-form { margin: 0; }

.topbar-sub {
  max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem 0.55rem;
}
.client-meta { font-size: 0.85rem; color: var(--muted); }
.client-meta strong { color: var(--ink-2); }
.client-meta .dot { margin: 0 0.4rem; color: var(--line); }

/* ===== レイアウト ===== */
.container { max-width: var(--maxw); margin: 0 auto; padding: 1.6rem 1.25rem 3rem; }
.page-head { margin-bottom: 1.2rem; }
.page-head h1 { margin-bottom: 0.2rem; }

.grid { display: grid; gap: 1rem; margin-bottom: 1rem; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.25rem 1.35rem; box-shadow: var(--shadow);
  margin-bottom: 1rem;
}
.card-title { font-size: 1.02rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.3rem; }
.card-link { font-size: 0.85rem; font-weight: 600; }
.section-title { font-size: 1.05rem; margin: 1.2rem 0 0.7rem; }

/* ===== 統計カード ===== */
.stat-card { display: flex; flex-direction: column; }
.stat-big { font-size: 2rem; font-weight: 700; color: var(--ink); margin: 0.2rem 0 0.5rem; line-height: 1.1; }
.stat-sub { font-size: 0.9rem; color: var(--muted); font-weight: 400; margin-left: 0.3rem; }
.card-link { margin-top: auto; }

/* ===== プログレスバー ===== */
.progress { height: 8px; background: var(--line-2); border-radius: 999px; overflow: hidden; margin-bottom: 0.7rem; }
.progress span { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.35s ease; }
.progress.mini { height: 6px; margin: 0; min-width: 90px; }

/* ===== バッジ・タグ ===== */
.tag {
  display: inline-block; font-size: 0.74rem; padding: 0.1rem 0.5rem; border-radius: 999px;
  background: var(--accent-weak); color: var(--accent-ink); font-weight: 600;
}
.tag-off { background: #eee; color: var(--muted); }
.badge { display: inline-block; font-size: 0.74rem; padding: 0.1rem 0.5rem; border-radius: 999px; font-weight: 600; }
.badge-draft { background: #eef0f2; color: var(--draft); }
.badge-used { background: #e6f0f7; color: var(--used); }
.badge-done { background: #e6f2ea; color: var(--done); }
.count-pill { font-size: 0.85rem; color: var(--muted); background: var(--line-2); padding: 0.15rem 0.6rem; border-radius: 999px; font-weight: 600; }
.period-badge { font-size: 0.78rem; color: var(--accent-ink); background: var(--accent-weak); padding: 0.1rem 0.5rem; border-radius: 6px; font-weight: 600; margin-left: 0.3rem; }

.delta { font-weight: 700; font-size: 0.9rem; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
.delta.flat { color: var(--muted); }

/* ===== テーブル ===== */
.table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.table th, .table td { padding: 0.55rem 0.6rem; border-bottom: 1px solid var(--line-2); text-align: left; }
.table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; }
.table.compact th, .table.compact td { padding: 0.45rem 0.5rem; }
.table tr.inactive td { color: var(--muted); }

/* ===== チェックリスト ===== */
.checklist { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.check-item { border-top: 1px solid var(--line-2); }
.check-item:first-child { border-top: none; }
.check-item label { display: flex; gap: 0.75rem; align-items: flex-start; padding: 0.75rem 0.2rem; cursor: pointer; }
.check-item input[type="checkbox"] { margin-top: 0.35rem; width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; cursor: pointer; }
.check-body { display: flex; flex-direction: column; }
.check-label { font-weight: 600; color: var(--ink); }
.check-hint { font-size: 0.85rem; color: var(--muted); margin-top: 0.1rem; }
.ref { font-size: 0.72rem; color: var(--accent); font-weight: 600; margin-left: 0.25rem; }
.check-item.is-checked .check-label { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

/* ===== フォーム ===== */
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label, .inline-field span, .rank-input-label { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.field-inline { flex-direction: row; align-items: center; gap: 0.6rem; }
input[type="text"], input[type="password"], input[type="date"], textarea, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 0.55rem 0.7rem; width: 100%;
}
textarea { resize: vertical; line-height: 1.7; }
select { cursor: pointer; }
.form-actions { display: flex; align-items: center; gap: 0.8rem; flex-wrap: wrap; }

/* ボタン */
.btn-primary, .btn-secondary, .btn-ghost {
  font: inherit; font-weight: 600; border-radius: 8px; padding: 0.55rem 1.1rem;
  cursor: pointer; border: 1px solid transparent; transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); }
.btn-secondary { background: var(--surface); color: var(--accent-ink); border-color: var(--accent); }
.btn-secondary:hover { background: var(--accent-weak); }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost:hover { background: var(--line-2); color: var(--ink-2); }
.btn-ghost.small, .btn-secondary.small { padding: 0.3rem 0.7rem; font-size: 0.82rem; }
button:disabled { opacity: 0.6; cursor: default; }

/* ===== アラート ===== */
.alert { padding: 0.7rem 0.9rem; border-radius: 8px; font-size: 0.9rem; margin-bottom: 1rem; }
.alert-error { background: #fbeceb; color: #92321d; border: 1px solid #f2cfc9; }
.alert-ok { background: #e9f4ee; color: #1f6b40; border: 1px solid #cfe7d8; }

/* ===== 投稿カード ===== */
.post-card-head { display: flex; align-items: center; justify-content: space-between; gap: 0.6rem; flex-wrap: wrap; }
.post-card-meta { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.char-count { font-size: 0.8rem; color: var(--muted); }
.post-body { min-height: 7rem; }
.post-card-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.inline-field { display: inline-flex; align-items: center; gap: 0.4rem; }
.inline-field select { width: auto; padding: 0.4rem 0.6rem; }
.post-card-actions .spacer { flex: 1; }
.post-mini-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.post-mini-list li { padding: 0.6rem 0; border-top: 1px solid var(--line-2); }
.post-mini-list li:first-child { border-top: none; }
.post-mini-meta { display: flex; gap: 0.4rem; margin-bottom: 0.2rem; }
.post-mini-body { font-size: 0.88rem; color: var(--ink-2); margin: 0; }

/* ===== 順位入力 ===== */
.rank-input-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.7rem; }
.rank-input { display: flex; flex-direction: column; gap: 0.25rem; }
.add-keyword { display: flex; gap: 0.5rem; margin-top: 0.9rem; }
.add-keyword input { flex: 1; }
form.inline { display: inline; margin: 0; }

/* ===== チャート ===== */
.chart-wrap { width: 100%; overflow-x: auto; }
.rank-chart { display: block; max-width: 100%; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 0.9rem; margin-top: 0.6rem; font-size: 0.82rem; color: var(--ink-2); }
.legend-item { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* ===== ログイン ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: 2rem 1.9rem; width: 100%; max-width: 380px; }
.login-head { text-align: center; margin-bottom: 1.4rem; }
.login-head h1 { margin: 0.7rem 0 0.3rem; font-size: 1.3rem; }
.login-form { display: flex; flex-direction: column; gap: 0.6rem; }
.login-form label { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.login-form button { margin-top: 0.5rem; }

/* ===== フッタ ===== */
.site-foot { max-width: var(--maxw); margin: 0 auto; padding: 1.5rem 1.25rem 2.5rem; color: var(--muted); font-size: 0.8rem; text-align: center; }

/* ===== レスポンシブ ===== */
@media (max-width: 820px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .mainnav { margin-left: 0; order: 3; width: 100%; overflow-x: auto; }
  .client-switch { margin-left: auto; }
}
@media (max-width: 520px) {
  body { font-size: 14.5px; }
  .container { padding: 1.1rem 0.9rem 2.5rem; }
  .card { padding: 1.05rem 1rem; }
  .topbar-inner { gap: 0.6rem; }
  .post-card-actions { gap: 0.45rem; }
  .rank-input-grid { grid-template-columns: 1fr 1fr; }
}
