/* 栄園デジタル黒板 — yamachikaseiya.com のトーンに合わせた最小構成 */

:root {
  color-scheme: light;

  /* site tokens */
  --text: #172033;
  --muted: #5c667a;
  --subtle: #f5f7fb;
  --border: #e2e7ef;
  --surface: #fff;
  --accent: #145fe8;
  --accent-dark: #0d47b8;
  --dark: #101522;
  --button-bg: #101522;
  --button-hover: #293043;
  --card-shadow: 0 16px 42px rgba(24, 39, 75, 0.09);
  --radius: 0.65rem;

  /* board */
  --board: #101522;
  --chalk: #eae6dc;
  --chalk-dim: #8f93a3;
  --note: #f3e9c8;
  --note-text: #2a2721;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--surface);
  color: var(--text);
  font-family: Inter, "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  line-height: 1.8;
  -webkit-text-size-adjust: 100%;
}

/* ==========================================================================
   黒板（閲覧・書き込み共通）
   ========================================================================== */

body[data-mode="view"],
body[data-mode="write"] {
  overflow: hidden;
  background: var(--board);
}

.stage-wrap {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
}

.stage {
  position: absolute;
  width: 1920px;
  height: 1080px;
  background: var(--board);
  transform-origin: top left;
  touch-action: pinch-zoom;
}

.stage-wrap.panning,
.stage-wrap.panning * { cursor: grabbing; }

#board-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.preview-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  touch-action: none;
}

#notes-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* ---- 付箋 ---- */

.note {
  position: absolute;
  width: max-content;
  min-width: 300px;
  max-width: 620px;
  min-height: 80px;
  max-height: 640px;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 20px;
  border-radius: 2px;
  background: var(--note);
  color: var(--note-text);
  font-size: 30px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  pointer-events: auto;
  cursor: default;
  transform: translate(-50%, -50%);
  outline: none;
}

.note[data-own="1"] { cursor: grab; }
.note.dragging { cursor: grabbing; }

.note .note-text {
  margin: 0;
  white-space: pre-wrap;
}
.note-text p { margin: 0 0 0.35em; }
.note-text p:last-child { margin-bottom: 0; }
.note-text h3 {
  margin: 0.1em 0 0.3em;
  font-size: 1.8em;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.note-text h4 {
  margin: 0.1em 0 0.25em;
  font-size: 1.45em;
  font-weight: 700;
  line-height: 1.25;
}
.note-text h5 {
  margin: 0.1em 0 0.2em;
  font-size: 1.2em;
  font-weight: 700;
  line-height: 1.3;
}
.note-text em {
  font-style: normal;
  display: inline-block;
  transform: skewX(-14deg);
  font-weight: 600;
}
.note-text ul { margin: 0.2em 0 0.45em; padding-left: 1.15em; }
.note-text li { margin: 0.1em 0; }
.note-text blockquote {
  margin: 0.3em 0;
  padding-left: 0.6em;
  border-left: 2px solid #cdbd85;
  color: #5a5238;
}
.note-text code {
  background: rgba(0, 0, 0, 0.07);
  padding: 0.05em 0.3em;
  border-radius: 3px;
  font-size: 0.9em;
}
.note-text a {
  color: var(--accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.note-embed {
  display: block;
  width: 440px;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  margin: 0.4em 0;
}
.note-empty { color: #94885e; }

/* 編集中だけ付箋の外に出す色パレット。付箋の高さを変えない。 */
.note-colors {
  position: absolute;
  z-index: 2;
  display: flex;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(24, 39, 75, 0.2);
  pointer-events: auto;
}

.note-colors .note-color {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 2px solid rgba(0, 0, 0, 0.12);
  border-radius: 50%;
  cursor: pointer;
}

.note-colors .note-color[aria-pressed="true"] {
  border-color: transparent;
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.note textarea {
  display: block;
  width: 100%;
  min-height: 120px;
  border: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  resize: none;
  outline: none;
  padding: 0;
  overflow-y: hidden;
}

/* 入力中に幅・高さを測るための不可視ミラー。確定後の .note-text と同じ組み方にする。 */
.note .note-mirror {
  position: absolute;
  left: 20px;
  top: 18px;
  visibility: hidden;
  pointer-events: none;
  word-break: break-word;
  font: inherit;
  line-height: inherit;
  margin: 0;
  padding: 0;
  border: 0;
}

/* ---- 書き込みツール ---- */

.tools {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  z-index: 10;
}

.tools button {
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 0.45rem;
  background: transparent;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.tools button:hover { background: var(--subtle); color: var(--text); }
.tools button[aria-pressed="true"] { background: var(--subtle); color: var(--text); }

.tools .swatch {
  width: 26px;
  height: 26px;
  margin: 0 3px;
  border-radius: 50%;
  background: var(--c);
  border: 1px solid rgba(0, 0, 0, 0.15);
}
.tools .swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.tools .size span {
  display: block;
  border-radius: 50%;
  background: currentColor;
}
.tools .size[aria-pressed="true"] span { background: var(--accent); }

.tools .sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 6px;
}

.tools svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.status {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  margin: 0;
  font-size: 12px;
  color: var(--chalk-dim);
  z-index: 10;
}

/* ==========================================================================
   参加・管理（サイトと同じ明るいトーン）
   ========================================================================== */

body[data-mode="join"],
body[data-mode="admin"] {
  overflow: auto;
  background: var(--subtle);
}

.panel {
  width: min(480px, calc(100vw - 32px));
  margin: 56px auto;
  padding: 28px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.panel h2 {
  margin: 0 0 14px;
  color: var(--dark);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.panel p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.75;
}

.panel label {
  display: block;
  margin: 16px 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
}

.panel input[type="text"],
.panel input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.panel input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.panel .actions {
  margin-top: 20px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

button,
.btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  padding: 9px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

button:hover,
.btn:hover { border-color: var(--muted); }

button.primary,
.btn.primary {
  background: var(--button-bg);
  border-color: var(--button-bg);
  color: #fff;
}
button.primary:hover,
.btn.primary:hover { background: var(--button-hover); border-color: var(--button-hover); }

button.danger { color: #b42318; border-color: #f0c9c4; }
button.danger:hover { background: #fdf3f2; border-color: #e3a9a2; }
button:disabled { opacity: 0.45; cursor: not-allowed; }

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.panel .error { min-height: 1.2em; color: #b42318; font-size: 0.78rem; }
.panel .ok { color: #1a7f4b; font-size: 0.85rem; }
.hint { font-size: 0.76rem; color: var(--muted); }
.notice {
  padding: 10px 12px;
  border-radius: 0.45rem;
  background: var(--subtle);
  border: 1px solid var(--border);
  font-size: 0.8rem;
}

.admin-wrap {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 40px 20px 96px;
}

.admin-wrap .panel { width: 100%; margin: 0 0 20px; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}
.admin-table th,
.admin-table td {
  text-align: left;
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.admin-table th { color: var(--muted); font-weight: 600; }
.admin-table .row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-table button { padding: 4px 10px; font-size: 0.72rem; }

.invite-url {
  display: block;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--subtle);
  border: 1px solid var(--border);
  border-radius: 0.45rem;
  font-size: 0.76rem;
  word-break: break-all;
  color: var(--text);
}

.hidden { display: none !important; }

.zoom-hint {
  display: block;
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  margin: 0;
  font-size: 11px;
  color: var(--chalk-dim);
  opacity: 0.65;
  z-index: 9;
  pointer-events: none;
  white-space: nowrap;
}

body[data-mode="write"] .zoom-hint { bottom: 72px; }

@media (max-width: 640px) {
  .panel { margin: 24px auto; padding: 22px; }
}

@media (max-width: 480px) {
  .tools { gap: 0; padding: 5px; }
  .tools button { width: 32px; height: 32px; }
  .tools .swatch { width: 22px; height: 22px; margin: 0 2px; }
  .tools .sep { margin: 0 3px; }
}
