/* =====================================================================
   みんなのひろば スタイル
   やさしい色・大きめの文字とボタン（指で押しやすい48px以上）
   ===================================================================== */
:root {
  --bg: #fbf6ee;
  --surface: #ffffff;
  --ink: #2b2a33;
  --ink-soft: #6b6874;
  --line: #ece4d8;
  --primary: #2f8f83;
  --primary-ink: #ffffff;
  --primary-soft: #e3f3f0;
  --like: #f0566b;
  --warn: #e8873a;
  --warn-soft: #fff1e4;
  --danger: #d64545;
  --radius: 18px;
  --shadow: 0 2px 0 rgba(43, 42, 51, .04), 0 6px 18px rgba(43, 42, 51, .06);
  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Meiryo", sans-serif;

  --g-low: #ffd9a8;   --g-low-ink: #8a4b00;    /* 小1・小2 */
  --g-mid: #c9ecc1;   --g-mid-ink: #2d6a1f;    /* 小3・小4 */
  --g-high: #c7e3ff;  --g-high-ink: #1d4f8a;   /* 小5・小6 */
  --g-jh: #e3d4ff;    --g-jh-ink: #5232a0;     /* 中学生 */
  --g-t: #3a3946;     --g-t-ink: #ffffff;      /* 先生 */
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-weight: 500;
  font-size: 17px;
  line-height: 1.6;
}
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.ico { display: inline-flex; width: 26px; height: 26px; }
.ico svg, .tool-btn svg, .act-btn svg, .send-btn svg, .dialog-mark svg {
  width: 100%; height: 100%;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.ico-xl { width: 56px; height: 56px; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 2px solid transparent; border-radius: 999px;
  font-weight: 700; cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-block { width: 100%; }
.btn-lg { min-height: 56px; font-size: 19px; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 15px; }
.btn .ico { width: 22px; height: 22px; }
.link-btn { background: none; border: 0; padding: 4px; color: var(--primary); font-weight: 700; cursor: pointer; }

/* ---------- 入力 ---------- */
.field { display: grid; gap: 6px; position: relative; }
.field-label { font-weight: 700; font-size: 15px; color: var(--ink-soft); }
input[type="text"], input[type="password"], textarea, select {
  width: 100%; min-height: 50px; padding: 10px 14px;
  background: #fff; border: 2px solid var(--line); border-radius: 14px;
  outline: none; transition: border-color .15s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; }
.counter { justify-self: end; font-size: 13px; color: var(--ink-soft); }

/* ---------- ログイン ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login-card {
  width: min(420px, 100%); background: var(--surface); border-radius: 28px;
  padding: 36px 28px 28px; box-shadow: var(--shadow); text-align: center;
}
.login-logo { display: flex; justify-content: center; gap: 8px; margin-bottom: 8px; }
.login-logo .dot { width: 22px; height: 22px; border-radius: 50%; }
.login-logo .d1 { background: var(--g-low); }
.login-logo .d2 { background: var(--g-mid); }
.login-logo .d3 { background: var(--g-high); }
.login-title { margin: 4px 0 4px; font-size: 30px; font-weight: 900; letter-spacing: .04em; }
.login-sub { margin: 0 0 24px; color: var(--ink-soft); font-size: 15px; }
.login-form { display: grid; gap: 16px; text-align: left; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 76px; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  min-height: 38px; padding: 0 12px; border: 0; border-radius: 10px;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; cursor: pointer;
}
.login-error { margin: 0; padding: 10px 14px; border-radius: 12px; background: var(--warn-soft); color: #9a4a0b; font-size: 15px; }
.login-note { margin: 18px 0 0; font-size: 14px; color: var(--ink-soft); }

/* ---------- 上部バー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: rgba(251, 246, 238, .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  max-width: 560px; margin: 0 auto; padding: 8px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.topbar-inner.wide { max-width: 1100px; }
.brand { margin: 0; font-size: 22px; font-weight: 900; letter-spacing: .04em; }
.brand small { font-size: 14px; font-weight: 700; color: var(--ink-soft); margin-left: 8px; }
.topbar-actions { display: flex; gap: 4px; }
.icon-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 0;
  min-width: 56px; padding: 4px 6px; border: 0; background: none;
  color: var(--ink); text-decoration: none; font-size: 11px; font-weight: 700; cursor: pointer;
}
.icon-btn .ico { width: 24px; height: 24px; }

/* ---------- タイムライン ---------- */
.feed-wrap { max-width: 560px; margin: 0 auto; padding: 12px 12px 120px; }
.me-banner { margin: 4px 4px 12px; font-size: 15px; color: var(--ink-soft); }
.feed { display: grid; gap: 16px; }
.feed-empty, .feed-loading { text-align: center; color: var(--ink-soft); padding: 32px 8px; }
#more-btn { margin-top: 16px; }

.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card.is-hidden { opacity: .6; outline: 3px dashed var(--warn); outline-offset: -3px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 10px; }
.card-meta { flex: 1; min-width: 0; display: grid; line-height: 1.3; }
.card-meta time { font-size: 13px; color: var(--ink-soft); }
.name-line { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.name { font-weight: 700; }
.card-tools { display: flex; align-items: center; gap: 4px; }

.avatar {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 900; font-size: 18px;
}

/* 学年バッジ（色＋文字の両方で区別） */
.grade {
  display: inline-block; padding: 1px 9px; border-radius: 999px;
  font-size: 13px; font-weight: 700; line-height: 1.6; white-space: nowrap;
}
.grade-sm { font-size: 11px; padding: 0 7px; }
.grade-low     { background: var(--g-low);  color: var(--g-low-ink); }
.grade-mid     { background: var(--g-mid);  color: var(--g-mid-ink); }
.grade-high    { background: var(--g-high); color: var(--g-high-ink); }
.grade-jh      { background: var(--g-jh);   color: var(--g-jh-ink); }
.grade-teacher { background: var(--g-t);    color: var(--g-t-ink); }

.hidden-banner { margin: 0; padding: 6px 12px; background: var(--warn-soft); color: #9a4a0b; font-size: 14px; font-weight: 700; }
.flag-badge {
  padding: 2px 8px; border-radius: 6px; background: var(--warn); color: #fff;
  font-size: 12px; font-weight: 700; white-space: nowrap;
}
.flag-badge.sm { font-size: 11px; padding: 0 6px; }

.card-media { background: #f3eee6; }
.card-img { width: 100%; max-height: 72vh; object-fit: contain; margin: 0 auto; user-select: none; -webkit-user-drag: none; }

.card-actions { display: flex; align-items: center; gap: 4px; padding: 6px 8px 0; }
.act-btn {
  width: 48px; height: 48px; padding: 10px; border: 0; background: none; cursor: pointer; color: var(--ink);
  border-radius: 50%;
}
.act-btn.like.on { color: var(--like); }
.act-btn.like.on svg { fill: var(--like); }
.act-btn.pop { animation: pop .35s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.3); } 100% { transform: scale(1); } }
.like-count { font-weight: 700; margin-left: 4px; }

.caption { margin: 2px 14px 6px; white-space: pre-wrap; overflow-wrap: anywhere; }
.caption-name { font-weight: 700; }

.comments { list-style: none; margin: 0; padding: 0 14px; display: grid; gap: 6px; }
.comment {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px;
  padding: 6px 10px; background: #faf7f2; border-radius: 12px; font-size: 15px;
}
.comment.is-hidden { opacity: .55; outline: 2px dashed var(--warn); }
.comment-name { font-weight: 700; }
.comment-body { flex-basis: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }
.comment-time { font-size: 12px; color: var(--ink-soft); margin-left: auto; }
.more-comments { padding: 0; }

.comment-form { display: flex; gap: 8px; padding: 10px 12px 14px; }
.comment-form input { flex: 1; min-height: 46px; border-radius: 999px; }
.send-btn {
  flex: none; width: 46px; height: 46px; padding: 11px; border: 0; border-radius: 50%;
  background: var(--primary); color: #fff; cursor: pointer;
}

.tool-btn {
  width: 36px; height: 36px; padding: 7px; border: 0; border-radius: 10px;
  background: none; color: var(--ink-soft); cursor: pointer;
}
.tool-btn:hover { background: #f3eee6; }
.tool-btn.danger { color: var(--danger); }
.tool-btn.sm { width: 30px; height: 30px; padding: 5px; }

/* ---------- 下部メニュー ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: center; gap: 8px;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line);
}
.nav-btn {
  flex: 1; max-width: 160px; min-height: 58px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; border-radius: 16px; font-size: 13px; font-weight: 700; cursor: pointer;
}
.nav-btn .ico { width: 28px; height: 28px; }
.nav-post { background: var(--primary); color: #fff; }

/* ---------- 投稿シート ---------- */
.sheet {
  width: min(520px, 100%); max-height: 100dvh; margin: auto auto 0; padding: 0;
  border: 0; border-radius: 24px 24px 0 0; background: var(--surface); color: var(--ink);
}
@media (min-width: 600px) { .sheet { margin: auto; border-radius: 24px; } }
.sheet::backdrop, .dialog::backdrop { background: rgba(43, 42, 51, .45); }
.sheet-inner { display: grid; gap: 14px; padding: 12px 18px calc(20px + env(safe-area-inset-bottom)); }
.sheet-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; }
.sheet-head h2 { margin: 0; text-align: center; font-size: 18px; }
.sheet-head-spacer { width: 76px; }
.photo-picker {
  display: grid; place-items: center; min-height: 220px; border-radius: 18px;
  border: 3px dashed var(--line); background: #faf7f2; cursor: pointer; overflow: hidden;
}
.photo-empty { display: grid; justify-items: center; gap: 6px; color: var(--ink-soft); font-weight: 700; }
.photo-preview { width: 100%; max-height: 46vh; object-fit: contain; }
.hint { margin: -6px 4px 0; font-size: 13px; color: var(--ink-soft); }

/* ---------- 確認ダイアログ ---------- */
.dialog {
  width: min(440px, calc(100% - 32px)); padding: 0; border: 0; border-radius: 24px;
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 50px rgba(0, 0, 0, .2);
}
.dialog-inner { padding: 26px 22px 20px; text-align: center; }
.dialog-mark {
  width: 64px; height: 64px; margin: 0 auto 6px; padding: 14px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
}
.dialog-warn .dialog-mark { background: var(--warn-soft); color: var(--warn); }
.dialog-title { margin: 0 0 8px; font-size: 21px; font-weight: 900; }
.dialog-body { color: var(--ink); text-align: left; }
.dialog-body p { margin: 0 0 10px; }
.dialog-actions { display: flex; gap: 10px; margin-top: 18px; }
.dialog-actions .btn { flex: 1; padding: 0 12px; white-space: nowrap; }
.quote {
  margin: 0; padding: 10px 14px; border-left: 4px solid var(--warn); background: var(--warn-soft);
  border-radius: 8px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.checklist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.checklist li {
  padding: 10px 12px 10px 40px; position: relative; background: #faf7f2; border-radius: 12px;
}
.checklist li::before {
  content: ""; position: absolute; left: 12px; top: 50%; width: 18px; height: 18px; margin-top: -9px;
  border: 2.5px solid var(--primary); border-radius: 6px;
}
.big-pw { font-size: 32px; font-weight: 900; text-align: center; letter-spacing: .12em; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: 96px; z-index: 50;
  transform: translate(-50%, 20px); opacity: 0;
  padding: 12px 20px; border-radius: 999px; background: var(--ink); color: #fff;
  font-weight: 700; box-shadow: var(--shadow); transition: all .25s ease; max-width: calc(100% - 32px);
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast-warn { background: var(--warn); }

/* ---------- 管理画面 ---------- */
body.admin { font-size: 15px; }
.admin-wrap { max-width: 1100px; margin: 0 auto; padding: 16px 16px 60px; }
.admin-denied { text-align: center; padding: 60px 16px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tab {
  min-height: 42px; padding: 0 16px; border: 2px solid var(--line); border-radius: 999px;
  background: var(--surface); font-weight: 700; cursor: pointer;
}
.tab.active { background: var(--ink); border-color: var(--ink); color: #fff; }
.panel { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.panel h2 { margin: 0 0 6px; font-size: 19px; }
.panel h3 { margin: 18px 0 8px; font-size: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.panel-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.note { color: var(--ink-soft); font-size: 14px; margin: 4px 0 12px; }
.inline { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; }
.inline select { min-height: 38px; width: auto; padding: 4px 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.row input[type="text"] { flex: 1; min-width: 180px; }
.row select { width: auto; }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; }
.small { font-size: 13px; color: var(--ink-soft); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.table th { color: var(--ink-soft); font-weight: 700; background: #faf7f2; }
.table tr.inactive td { color: #aaa; }
.table tr.error-row td { background: #fff3f3; }
.table td.actions .btn + .btn { margin-left: 6px; }
.pw-cell .masked { letter-spacing: .1em; color: var(--ink-soft); }
.pw-cell .link-btn { margin-left: 8px; font-size: 13px; }

.review-list { display: grid; gap: 10px; }
.review-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center;
  padding: 10px; border: 1px solid var(--line); border-radius: 14px;
}
.review-item.is-hidden { background: #faf7f2; }
.review-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; }
.review-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.review-text { margin: 4px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.review-actions { display: flex; gap: 6px; }
.empty { color: var(--ink-soft); }
@media (max-width: 640px) {
  .review-item { grid-template-columns: 1fr; }
  .review-thumb { width: 100%; height: 160px; }
}

.word-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .word-columns { grid-template-columns: 1fr; } }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 12px;
  border-radius: 999px; font-weight: 700;
}
.chip-ng { background: #ffe4e4; color: #9b2020; }
.chip-ok { background: var(--primary-soft); color: var(--primary); }
.chip-x { width: 26px; height: 26px; border: 0; border-radius: 50%; background: rgba(0, 0, 0, .07); cursor: pointer; }

/* ---------- 印刷（ID・パスワード配布用） ---------- */
@media print {
  body { background: #fff; font-size: 12px; }
  .topbar, .tabs, .panel-tools, .no-print, .note, #tab-create, #tab-review, #tab-words, .toast { display: none !important; }
  .panel { box-shadow: none; padding: 0; }
  .table th, .table td { border: 1px solid #999; padding: 6px 8px; }
}

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