/* ===== 칠판 공통 ===== */

svg { flex: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:hover { background: color-mix(in srgb, currentColor 10%, transparent); }

.menu {
  position: fixed;
  z-index: 50;
  display: flex;
  flex-direction: column;
  min-width: 11rem;
  padding: 0.35rem;
  border: 1px solid var(--rule);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
}
.menu[hidden] { display: none; }
.menu button {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  width: 100%;
  padding: 0.45rem 0.7rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 0.9375rem;
  line-height: 1.4;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.menu button:hover,
.menu button:focus-visible { background: color-mix(in srgb, currentColor 9%, transparent); outline: none; }
.menu button[hidden] { display: none; }
.menu svg { width: 18px; height: 18px; }
.menu hr { margin: 0.3rem 0.2rem; border: 0; border-top: 1px solid var(--rule); }
.menu kbd { margin-left: auto; padding-left: 1.5rem; font: 500 0.75rem var(--sans); opacity: 0.55; }
.menu .danger { color: var(--seal); }

.dialog {
  width: min(30rem, calc(100% - 2rem));
  padding: 1.5rem;
  border: 1px solid var(--rule);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.dialog::backdrop { background: rgba(10, 20, 16, 0.5); }
.dialog h2 { font-size: 1.375rem; font-weight: 600; }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; }
.dialog__actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.5rem; }
.dialog p { margin-top: 0.75rem; line-height: 1.65; }

.field { display: grid; gap: 0.4rem; margin-top: 1rem; font-weight: 500; }
.field input {
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 400;
}

.ghost {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: transparent;
  font-size: 0.875rem;
  cursor: pointer;
}
.ghost:hover { border-color: var(--ink-soft); }
.ghost[hidden] { display: none; }
.ghost svg { width: 18px; height: 18px; }

.primary {
  padding: 0.45rem 1.1rem;
  border: 0;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  cursor: pointer;
}
.primary.danger { background: var(--seal); color: #fff; }

.toast {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 1.5rem;
  max-width: calc(100% - 2rem);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  background: var(--ink);
  color: var(--paper);
  font-size: 0.9375rem;
  line-height: 1.5;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 0.75rem);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ===== 칠판 목록 ===== */

.boards { padding-block: clamp(2rem, 6vw, 4rem) clamp(3rem, 8vw, 6rem); }

.boards__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}
.boards__title {
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  letter-spacing: -0.02em;
}
.boards__count {
  font-family: var(--sans);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}
.boards__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
.boards__error {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid var(--seal);
  background: color-mix(in srgb, var(--seal) 8%, transparent);
}
.boards__error[hidden] { display: none; }
.boards__error .ghost { margin-left: 0.5rem; }
.boards__empty { padding: 2rem 0; color: var(--ink-soft); list-style: none; }

/* 저장 위치 고르기 (칸반과 같은 모양) */
.store-pick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--rule);
}
.store-pick .seg { flex: none; border-radius: 10px; }
.store-pick .seg button { padding: 0.35rem 0.9rem; font-size: 0.9375rem; font-weight: 600; }
.store-pick__text { flex: 1 1 22rem; max-width: 46rem; color: var(--ink-soft); font-size: 0.9375rem; line-height: 1.6; }

.dialog__error { color: var(--seal); font-weight: 600; }
.dialog__error[hidden] { display: none; }

.seg { display: inline-flex; padding: 3px; border: 1px solid var(--rule); border-radius: 9px; }
.seg button {
  padding: 0.3rem 0.75rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.875rem;
  cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }

.boards__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 1.75rem 1.25rem;
  margin-top: 2rem;
  padding: 0;
  list-style: none;
}
.tile-wrap { position: relative; }
.tile { display: flex; flex-direction: column; color: inherit; text-decoration: none; }
.tile__thumb {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  margin-bottom: 0.6rem;
  overflow: hidden;
  border-radius: 6px;
  background: var(--board);
  color: var(--chalk);
}
.tile__thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 5px #5B4632, inset 0 0 0 6px #3E2F22;
  pointer-events: none;
}
.tile__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile:hover .tile__thumb,
.tile:focus-visible .tile__thumb { outline: 2px solid var(--seal); outline-offset: 2px; }
.tile:focus-visible { outline: none; }
.tile__title { overflow: hidden; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.tile__date { font-size: 0.8125rem; color: var(--ink-soft); }
.tile__private { margin-right: 0.4rem; padding: 0 0.4rem; border: 1px solid currentColor; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }

.tile--new .tile__thumb { border: 1.5px dashed var(--rule); background: transparent; color: var(--ink-soft); }
.tile--new .tile__thumb::after { display: none; }
.tile--new .tile__thumb svg { width: 32px; height: 32px; }
.tile--new:hover .tile__thumb { border-color: var(--seal); color: var(--seal); outline: none; }

.tile__more {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 7px;
  background: rgba(14, 28, 24, 0.72);
  color: var(--chalk);
  cursor: pointer;
}
.tile__more svg { width: 18px; height: 18px; }
.tile__more:hover { background: rgba(14, 28, 24, 0.92); }

.help-list { display: grid; gap: 1.1rem; padding: 0; list-style: none; }
.help-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 0.9rem; }
.help-list svg { width: 22px; height: 22px; margin-top: 0.15rem; color: var(--seal); }
.help-list h3 { margin-bottom: 0.15rem; font-family: var(--sans); font-size: 1rem; font-weight: 600; }
.help-list p { margin: 0; color: var(--ink-soft); font-size: 0.9375rem; line-height: 1.6; }

/* ===== 칠판 편집 화면 =====
   다크 모드는 초록 칠판, 라이트 모드는 하얀 화이트보드입니다. */

.editor {
  --ed-bg: #1F3A33;
  --ed-ink: #EEF0E8;
  --ed-muted: rgba(238, 240, 232, 0.5);
  --ed-panel: rgba(14, 28, 24, 0.92);
  --ed-menu: rgba(14, 28, 24, 0.97);
  --ed-dialog: #14261F;
  --ed-hover: rgba(238, 240, 232, 0.08);
  --ed-line: rgba(238, 240, 232, 0.13);
  --ed-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  --accent: #FF8A7E;
  --accent-bg: rgba(255, 138, 126, 0.18);
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: var(--ed-bg);
  color: var(--ed-ink);
  font-size: 0.9375rem;
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
:root[data-theme="light"] .editor {
  --ed-bg: #F6F7F3;
  --ed-ink: #1E2B27;
  --ed-muted: rgba(30, 43, 39, 0.5);
  --ed-panel: rgba(255, 255, 255, 0.94);
  --ed-menu: #FFFFFF;
  --ed-dialog: #FFFFFF;
  --ed-hover: rgba(30, 43, 39, 0.06);
  --ed-line: rgba(30, 43, 39, 0.12);
  --ed-shadow: 0 6px 20px rgba(30, 43, 39, 0.12);
  --accent: #C8312A;
  --accent-bg: rgba(200, 49, 42, 0.1);
}
.editor :focus-visible { outline-color: var(--accent); }

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

.panel {
  border: 1px solid var(--ed-line);
  border-radius: 12px;
  background: var(--ed-panel);
  box-shadow: var(--ed-shadow);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.titlebar {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  left: 12px;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100% - 24px);
  padding: 4px;
}
.titlebar .icon-btn:hover { background: var(--ed-hover); }
.title-btn {
  max-width: 16rem;
  overflow: hidden;
  padding: 0.35rem 0.6rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
}
.title-btn:hover { background: var(--ed-hover); }
.title-input {
  width: 14rem;
  max-width: calc(100vw - 130px);
  padding: 0.35rem 0.6rem;
  border: 0;
  border-radius: 8px;
  outline: 2px solid var(--accent);
  background: var(--ed-hover);
  color: inherit;
  font: inherit;
  font-weight: 600;
}
.title-input::placeholder { color: var(--ed-muted); }
.title-badge {
  flex: none;
  padding: 0.05rem 0.55rem;
  border: 1px solid var(--ed-line);
  border-radius: 999px;
  color: var(--ed-muted);
  font-size: 0.8125rem;
  font-weight: 600;
}
.title-badge[hidden],
.title-edit[hidden] { display: none; }
/* 서버 칠판 공개/비공개 바꾸기 */
.title-private { background: transparent; font-family: inherit; cursor: pointer; }
.title-private:hover { background: var(--ed-hover); }
.title-private[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.title-edit {
  flex: none;
  padding: 0.3rem 0.75rem;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: var(--ed-bg);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
}

/* 서버 칠판을 로그인 없이 볼 때: 그리기 도구는 숨기고 화면 이동, 확대, 내려받기만 남깁니다 */
.is-readonly .toolbar [data-tool]:not([data-tool="hand"]),
.is-readonly #shape-more,
.is-readonly #save,
.is-readonly #undo,
.is-readonly #redo,
.is-readonly .toolbar .sep:last-of-type,
.is-readonly .palette,
.is-readonly .hint,
.is-readonly #more-menu [data-act="image"] { display: none !important; }
.is-readonly .toolbar [data-tool="hand"] { display: grid !important; }
.is-readonly .title-btn { cursor: default; }
.is-readonly .title-btn:hover { background: transparent; }

.dialog__list { margin: 0.75rem 0 0; padding-left: 1.1em; line-height: 1.6; }
.dialog--board .dialog__list,
.dialog--board p { color: var(--ed-muted); }
.dialog--board .dialog__list strong { color: var(--ed-ink); }
.dialog--board .field input { border-color: var(--ed-line); background: var(--ed-hover); }
.dialog--board .ghost { border-color: var(--ed-line); }
.dialog--board .primary { background: var(--accent); color: var(--ed-bg); }

.minimap {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  right: 12px;
  width: 200px;
  height: 128px;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
}
.minimap[hidden] { display: none; }

.palette {
  position: fixed;
  top: 50%;
  left: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 5px;
  transform: translateY(-50%);
}
.palette[hidden],
.palette__colors[hidden] { display: none; }
.palette__colors,
.palette__sizes { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.palette__sep { width: 18px; height: 1px; margin: 4px 0; background: var(--ed-line); }

.swatch {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
}
.swatch::before {
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.25);
}
#note-colors .swatch::before { border-radius: 3px; }
.swatch[aria-pressed="true"],
.swatch--custom.is-on { box-shadow: inset 0 0 0 2px var(--accent); }
.swatch--custom::before { background: conic-gradient(#F4D35E, #F2A65A, #F49AB0, #B9A6F2, #8EC9F0, #A8DA8C, #F4D35E); }
.swatch--custom.is-on::before { background: var(--c); }
.swatch--custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.swatch--custom:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }

.size {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}
.size span { display: block; border-radius: 50%; background: var(--ed-ink); }
.size:hover { background: var(--ed-hover); }
.size[aria-pressed="true"] { background: var(--accent-bg); }
.size[aria-pressed="true"] span { background: var(--accent); }

.toolbar {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  left: 50%;
  display: flex;
  align-items: center;
  gap: 2px;
  max-width: calc(100% - 24px);
  padding: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  transform: translateX(-50%);
}
.tool {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.tool svg { width: 20px; height: 20px; }
.tool--narrow { width: 18px; margin-left: -2px; }
.tool--narrow svg { width: 16px; height: 16px; }
.tool:hover:not(:disabled),
.zoom-label:hover { background: var(--ed-hover); }
.tool[aria-pressed="true"] { background: var(--accent-bg); color: var(--accent); }
.tool:disabled { opacity: 0.35; cursor: default; }
.sep { flex: none; width: 1px; height: 22px; margin: 0 4px; background: var(--ed-line); }
.zoom-label {
  flex: none;
  min-width: 3.4rem;
  height: 36px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 0.8125rem;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.menu--board { border-color: var(--ed-line); background: var(--ed-menu); color: var(--ed-ink); }
.menu--board hr { border-top-color: var(--ed-line); }
.menu--board [aria-checked="true"] { color: var(--accent); }

.editor kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 0.4em;
  border: 1px solid var(--ed-line);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 500 0.75rem/1.6 var(--sans);
  text-align: center;
}
.editor .menu kbd { border: 0; padding: 0 0 0 1.5rem; }

.hint {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.5rem;
  color: var(--ed-muted);
  text-align: center;
  pointer-events: none;
}
.hint[hidden] { display: none; }
.hint__title { font-family: "Gaegu", cursive; font-size: 2rem; }
.hint__keys { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.35rem; font-size: 0.875rem; }
.hint__keys kbd:not(:first-child) { margin-left: 0.6rem; }

.text-editor {
  position: fixed;
  z-index: 5;
  min-width: 1ch;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  outline: 1px dashed var(--ed-muted);
  outline-offset: 4px;
  background: transparent;
  font-family: "Gaegu", "Nanum Pen Script", cursive;
  line-height: 1.25;
  white-space: pre;
  resize: none;
  caret-color: currentColor;
  -webkit-user-select: text;
  user-select: text;
}
.text-editor[hidden] { display: none; }
.text-editor:focus-visible { outline: 1px dashed var(--ed-muted); }
/* 메모 안에서는 메모지 폭에 맞춰 줄을 바꿉니다. (칠판에 그릴 때의 줄바꿈과 같게) */
.text-editor.is-note,
.text-editor.is-note:focus-visible {
  outline: none;
  white-space: pre-wrap;
  word-break: normal;
  overflow-wrap: anywhere;
}

.dialog--board { border-color: var(--ed-line); background: var(--ed-dialog); color: var(--ed-ink); }
.keys { display: grid; gap: 0.5rem; max-height: 65vh; overflow: auto; }
.keys div { display: flex; justify-content: space-between; gap: 1rem; }
.keys dt { color: var(--ed-muted); }
.keys dd { text-align: right; }

.notice {
  position: fixed;
  top: 50%;
  left: 50%;
  display: grid;
  gap: 0.75rem;
  width: min(27rem, calc(100% - 2rem));
  padding: 1.5rem;
  transform: translate(-50%, -50%);
}
.notice[hidden] { display: none; }
.notice h1 { font-size: 1.375rem; }
.notice p { color: var(--ed-muted); line-height: 1.6; }
.notice .button { background: var(--ed-ink); color: var(--ed-bg); }
.is-missing #board,
.is-missing .titlebar,
.is-missing .minimap,
.is-missing .palette,
.is-missing .toolbar { display: none; }

.editor .toast {
  top: max(1rem, env(safe-area-inset-top));
  bottom: auto;
  background: var(--ed-ink);
  color: var(--ed-bg);
  transform: translate(-50%, -0.75rem);
}
.editor .toast.is-on { transform: translate(-50%, 0); }

@media (max-width: 600px) {
  .wide { display: none; }
  .toolbar { gap: 0; }
  .tool { width: 32px; height: 34px; }
  .tool--narrow { width: 18px; }
  .palette {
    top: auto;
    bottom: calc(max(12px, env(safe-area-inset-bottom)) + 56px);
    left: 50%;
    flex-direction: row;
    gap: 0;
    max-width: calc(100% - 24px);
    padding: 4px 6px;
    overflow-x: auto;
    scrollbar-width: none;
    transform: translateX(-50%);
  }
  .palette__colors,
  .palette__sizes { flex-direction: row; gap: 0; }
  .palette__sep { width: 1px; height: 18px; margin: 0 4px; }
  .swatch,
  .size { width: 26px; height: 26px; }
  .swatch::before { width: 16px; height: 16px; }
  .minimap { width: 120px; height: 80px; }
  .title-btn { max-width: 8rem; }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
