/* Teams掲示板：Google Keep 風の見た目。スマホ（片手）を最優先に作っている */
:root {
  --bg: #ffffff;
  --fg: #202124;
  --muted: #5f6368;
  --line: #e0e0e0;
  --chip: #f1f3f4;
  --chip-active: #feefc3;
  --accent: #5b5fc7;
  --accent-fg: #ffffff;
  --danger: #c5221f;
  --shadow: 0 1px 2px rgba(60, 64, 67, .3), 0 1px 3px 1px rgba(60, 64, 67, .15);

  /* メモの色（Keep の淡い色に近いもの） */
  --c-none: #ffffff;
  --c-coral: #faafa8;
  --c-peach: #f39f76;
  --c-sand: #fff8b8;
  --c-mint: #e2f6d3;
  --c-sage: #b4ddd3;
  --c-fog: #d4e4ed;
  --c-storm: #aeccdc;
  --c-dusk: #d3bfdb;
  --c-blossom: #f6e2dd;
  --c-clay: #e9e3d4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #202124;
    --fg: #e8eaed;
    --muted: #9aa0a6;
    --line: #5f6368;
    --chip: #303134;
    --chip-active: #41331c;
    --accent: #8b8ff0;
    --accent-fg: #111111;
    --danger: #f28b82;
    --shadow: 0 1px 2px rgba(0, 0, 0, .6), 0 1px 3px 1px rgba(0, 0, 0, .3);

    --c-none: #202124;
    --c-coral: #77172e;
    --c-peach: #692b17;
    --c-sand: #7c4a03;
    --c-mint: #264d3b;
    --c-sage: #0c625d;
    --c-fog: #256377;
    --c-storm: #284255;
    --c-dusk: #472e5b;
    --c-blossom: #6c394f;
    --c-clay: #4b443a;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 16px; /* 16px 未満だと iPhone で入力時に拡大されてしまう */
  line-height: 1.6;
  overflow-wrap: anywhere;
}
a { color: var(--accent); }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---- ボタン ---- */
.btn-primary, .btn-outline, .btn-text {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 44px; padding: 0 18px;
  border-radius: 22px; border: 0;
  font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-outline { background: transparent; border: 1px solid var(--line); color: var(--fg); }
.btn-text { background: transparent; color: var(--accent); padding: 0 10px; }
.btn-wide { width: 100%; }
button:disabled { opacity: .6; }

.alert { background: #fce8e6; color: var(--danger); padding: 10px 12px; border-radius: 8px; }
@media (prefers-color-scheme: dark) { .alert { background: #3c1f1e; } }
.notice { background: var(--chip); padding: 10px 12px; border-radius: 8px; }
.muted { color: var(--muted); }

/* ---- 上部バー ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-row { display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; }
.app-name { display: flex; align-items: center; gap: 8px; color: var(--fg); text-decoration: none; font-size: 18px; font-weight: 600; }
.app-name img { border-radius: 6px; }

.account { position: relative; }
.account summary { list-style: none; cursor: pointer; }
.account summary::-webkit-details-marker { display: none; }
.account-menu {
  position: absolute; right: 0; top: 44px; min-width: 220px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow); padding: 12px; z-index: 20;
}
.account-menu p { margin: 0 0 8px; }
.account-menu small { color: var(--muted); }

.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: var(--accent-fg);
  font-weight: 700; font-size: 15px; flex: none;
}

/* ラベル（チャネル）は横にスクロールするチップ */
.labels {
  display: flex; gap: 8px; overflow-x: auto; padding: 0 12px 10px;
  scrollbar-width: none;
}
.labels::-webkit-scrollbar { display: none; }
.label {
  flex: none; padding: 6px 16px; border-radius: 16px;
  background: var(--chip); color: var(--fg); text-decoration: none; font-size: 14px;
}
.label.active { background: var(--chip-active); font-weight: 700; }

/* ---- 一覧 ---- */
.board { padding: 12px 8px 96px; max-width: 1200px; margin: 0 auto; }

.take-note {
  display: block; max-width: 600px; margin: 4px auto 16px;
  padding: 12px 16px; border-radius: 8px;
  box-shadow: var(--shadow); background: var(--bg);
  color: var(--muted); text-decoration: none; font-weight: 500;
}

/* メモを Keep のように段組みで並べる（スマホは2列） */
.notes { column-count: 2; column-gap: 8px; }
@media (min-width: 700px) { .notes { column-count: 3; column-gap: 12px; } }
@media (min-width: 1000px) { .notes { column-count: 4; } }
/* JS で列に振り分けた後（振り分け前・JS が無い場合は上の段組みのまま） */
.notes.masonry { column-count: auto; display: flex; gap: 8px; align-items: flex-start; }
.notes-col { flex: 1; min-width: 0; }
@media (min-width: 700px) { .notes.masonry { gap: 12px; } }

.note {
  position: relative;
  break-inside: avoid;
  margin: 0 0 8px;
  padding: 12px 12px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--c-none);
}
.note-title { margin: 0 0 6px; font-size: 16px; font-weight: 700; line-height: 1.4; }
.note-body { font-size: 14px; }
.note-body p { margin: 0 0 .5em; }
.note-body > :last-child { margin-bottom: 0; }
.note-body ul, .note-body ol { padding-left: 1.3em; margin: 0 0 .5em; }
.note-body blockquote { margin: 0 0 .5em; padding-left: .8em; border-left: 3px solid var(--line); color: var(--muted); }
.note-body pre, .note-body code { white-space: pre-wrap; font-size: 13px; }
.note-body table { border-collapse: collapse; }
.note-body td, .note-body th { border: 1px solid var(--line); padding: 2px 6px; }
.clamp { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 10; overflow: hidden; }
.note-attach { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.note-meta {
  display: flex; flex-wrap: wrap; gap: 4px 8px; margin-top: 8px;
  font-size: 12px; color: var(--muted);
}
.note-author { font-weight: 700; }
.note-replies { margin-left: auto; }
/* カード全体を押せるようにする透明なリンク */
.note-link { position: absolute; inset: 0; border-radius: 8px; }
.note-link:focus-visible { outline: 2px solid var(--accent); }
.deleted { color: var(--muted); font-style: italic; margin: 0; }

.color-coral { background: var(--c-coral); }
.color-peach { background: var(--c-peach); }
.color-sand { background: var(--c-sand); }
.color-mint { background: var(--c-mint); }
.color-sage { background: var(--c-sage); }
.color-fog { background: var(--c-fog); }
.color-storm { background: var(--c-storm); }
.color-dusk { background: var(--c-dusk); }
.color-blossom { background: var(--c-blossom); }
.color-clay { background: var(--c-clay); }
.note[class*="color-"]:not(.color-none) { border-color: transparent; }
.avatar[class*="color-"] { color: var(--fg); }

.empty { text-align: center; color: var(--muted); margin: 48px 16px; }
.pager { display: flex; justify-content: center; gap: 12px; margin: 16px 0; }

/* 右下の ＋ ボタン */
.fab {
  position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent); color: var(--accent-fg);
  font-size: 32px; text-decoration: none; box-shadow: var(--shadow);
}

/* ---- 詳細・書く画面の上部バー ---- */
.subbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.back {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border-radius: 50%;
  color: var(--fg); text-decoration: none; font-size: 22px;
}
.subbar-title { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- 詳細（スレッド） ---- */
.thread { max-width: 720px; margin: 0 auto; padding: 12px 12px 220px; } /* 下の返信欄（画像のプレビュー込み）に隠れないように */
.note-open { padding: 16px; }
.note-open .note-title { font-size: 20px; }
.note-open .note-body { font-size: 16px; }
.attachments { list-style: none; padding: 0; margin: 8px 0 0; font-size: 14px; }
.attachments li { margin: 4px 0; }
.replies-head { font-size: 14px; color: var(--muted); margin: 20px 4px 8px; }
.replies { list-style: none; padding: 0; margin: 0; }
.reply { display: flex; gap: 8px; margin: 0 0 12px; }
.reply-bubble { flex: 1; min-width: 0; background: var(--chip); border-radius: 4px 14px 14px 14px; padding: 8px 12px; }
.reply.mine .reply-bubble { background: var(--chip-active); }
.reply-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.reply-meta b { color: var(--fg); }

/* 返信欄（画面下に固定） */
.reply-box {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  background: var(--bg); border-top: 1px solid var(--line);
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
}
.reply-box .alert { margin: 0 0 8px; }
.reply-box-row { display: flex; gap: 8px; align-items: flex-end; max-width: 720px; margin: 0 auto; }
.reply-box textarea {
  flex: 1; min-height: 44px; max-height: 40vh; resize: none;
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 22px;
  background: var(--bg);
}

/* ---- 書く画面 ---- */
.compose-body { max-width: 720px; margin: 0 auto; padding: 12px 16px 40px; }
.compose-title, .compose-text {
  display: block; width: 100%; border: 0; outline: none; background: transparent;
}
.compose-title { font-size: 20px; font-weight: 700; padding: 8px 0; }
.compose-text { min-height: 30vh; resize: none; padding: 8px 0; line-height: 1.7; }
.compose-label { display: block; margin-top: 16px; font-size: 14px; color: var(--muted); }
.compose-label select {
  display: block; width: 100%; margin-top: 4px; min-height: 44px;
  padding: 0 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg);
}
.compose-hint { font-size: 13px; color: var(--muted); }

/* ---- ログイン ---- */
.login { max-width: 440px; margin: 0 auto; padding: calc(40px + env(safe-area-inset-top)) 20px 40px; }
.login h1 { font-size: 24px; margin: 12px 0 8px; }
.login-logo { border-radius: 16px; }
.login-note { margin: 0 0 8px; }
.login-points { padding-left: 1.2em; margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.login-points li { margin: 4px 0; }
.login-small { font-size: 13px; text-align: center; margin-top: 16px; }

/* ---- 通知（下から出て消える） ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #323232; color: #fff; padding: 10px 20px; border-radius: 8px;
  box-shadow: var(--shadow); z-index: 30; transition: opacity .4s;
}
.toast.hide { opacity: 0; pointer-events: none; }

/* ---- 画像 ---- */
.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* 投稿の画像。一覧のカードでは Keep のようにカードの上端いっぱいに出す */
.note-images { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; overflow: hidden; }
.note-images.n1 { grid-template-columns: 1fr; }
.note-images img { display: block; width: 100%; height: 100%; object-fit: cover; aspect-ratio: 1 / 1; background: var(--chip); }
.note-images.n1 img { aspect-ratio: auto; max-height: 320px; }
.note-images.n3 > :first-child { grid-column: 1 / -1; }
.note-images.n3 > :first-child img { aspect-ratio: 2 / 1; }
.note > .note-images { margin: -12px -12px 10px; border-radius: 7px 7px 0 0; }

/* 詳細画面では画像を大きく（押すと原寸で開く） */
.note-open .note-images { margin: 12px 0 0; border-radius: 8px; grid-template-columns: 1fr; gap: 6px; }
.note-open .note-images img,
.note-open .note-images.n3 > :first-child img { aspect-ratio: auto; max-height: none; object-fit: contain; }
.reply-bubble .note-images { margin-top: 6px; border-radius: 8px; max-width: 280px; }
.reply-bubble .note-images.n1 img { max-height: 240px; }

/* 画像の追加 */
.img-picker { margin-top: 12px; }
.img-previews { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.img-preview {
  position: relative; width: 76px; height: 76px; border-radius: 8px; overflow: hidden;
  background: var(--chip); border: 1px solid var(--line);
}
.img-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.img-preview.loading::after {
  content: "縮小中…"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--muted);
}
.img-remove {
  position: absolute; top: 2px; right: 2px; width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(0, 0, 0, .65); color: #fff; font-size: 16px; line-height: 26px; padding: 0; cursor: pointer;
}
.img-add { cursor: pointer; }
.img-add.is-full { display: none; }
.img-note { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.img-count { margin-left: 6px; font-weight: 700; color: var(--fg); }

/* 返信欄：📷ボタンを入力欄の左に置き、プレビューと注意書きは入力欄の上に出す */
.reply-box-row { flex-wrap: wrap; }
.img-picker.compact { display: contents; }
.img-picker.compact .img-previews { order: -2; flex-basis: 100%; margin: 0; }
.img-picker.compact .img-note { order: -1; flex-basis: 100%; margin: 0; display: none; }
.img-picker.compact.has-images .img-note { display: block; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 44px; height: 44px; border-radius: 50%; background: var(--chip); font-size: 20px;
}
