:root {
  --bg: #f3f3f0;
  --ink: #222;
  --muted: #777;
  --line: rgba(0, 0, 0, .09);
  --paper: #d9f2b4;
  --accent: #3b7d2a;
  font-size: 17px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Malgun Gothic", "맑은 고딕", system-ui, -apple-system, "Noto Sans KR", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }

/* ---- 공통 상단 ---- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 1.15rem; margin: 0; flex: 1; }
.iconbtn {
  border: 0; background: transparent; border-radius: 8px;
  min-width: 40px; height: 40px; padding: 0 8px;
  font-size: 1.15rem; line-height: 1;
}
.iconbtn:hover { background: rgba(0, 0, 0, .07); }
.install {
  border: 0; border-radius: 999px; padding: 8px 12px;
  background: var(--accent); color: #fff; font-size: .85rem; font-weight: 600;
}
.status { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.status.online { color: var(--accent); }

/* ---- 로그인 ---- */
.login { max-width: 360px; margin: 18vh auto 0; padding: 24px; }
.login h1 { font-size: 1.4rem; }
.login input { width: 100%; padding: 12px; font-size: 1.1rem; border: 1px solid #bbb; border-radius: 10px; }
.login button { margin-top: 12px; width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font-size: 1.05rem; }
.login .err { color: #c0392b; min-height: 1.4em; margin-top: 8px; }

/* ---- 메모 목록 ---- */
.grid {
  display: grid; gap: 12px; padding: 12px;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  align-items: start;
}
.card {
  background: var(--c, var(--paper)); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12); cursor: pointer; min-height: 70px;
}
.card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.card .preview { font-size: .95rem; line-height: 1.5; white-space: pre-wrap; overflow: hidden; max-height: 9em; }
.card .meta { margin-top: 6px; font-size: .78rem; color: rgba(0, 0, 0, .5); }
.newrow { display: flex; gap: 8px; padding: 12px 12px 0; }
.newrow button { flex: 1; padding: 12px; border: 1px dashed #aaa; border-radius: 12px; background: #fff; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---- 메모 편집 ---- */
.memo { min-height: 100vh; background: var(--c, var(--paper)); }
.memo .topbar { background: var(--c, var(--paper)); border-bottom-color: rgba(0, 0, 0, .08); }
.title {
  flex: 1; min-width: 0; border: 0; background: transparent; outline: none;
  font-size: 1.15rem; font-weight: 700; padding: 6px 4px;
}
.addbox {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 12px 4px; padding: 6px 10px;
  background: rgba(255, 255, 255, .6); border-radius: 10px;
}
.addbox input { flex: 1; border: 0; background: transparent; outline: none; padding: 8px 2px; font-size: 1.05rem; }
.addbox .plus { color: var(--muted); font-size: 1.3rem; }

.daygroup { padding: 4px 0; }
.dayhead {
  font-size: .82rem; font-weight: 700; color: rgba(0, 0, 0, .55);
  padding: 10px 16px 2px; letter-spacing: .02em;
}
.items { list-style: none; margin: 0; padding: 0; min-height: 4px; }
.item {
  display: flex; align-items: flex-start; gap: 6px;
  padding: 2px 8px 2px 4px; background: transparent;
}
.item .handle {
  cursor: grab; touch-action: none; color: rgba(0, 0, 0, .3);
  padding: 9px 4px; font-size: .95rem; user-select: none; line-height: 1;
}
.item input[type=checkbox] { width: 20px; height: 20px; margin: 9px 4px 0; accent-color: #555; flex: none; }
.item textarea {
  flex: 1; border: 0; background: transparent; outline: none; resize: none;
  padding: 7px 2px; line-height: 1.45; overflow: hidden; min-height: 1.45em; font-size: 1.02rem;
}
.item .del { opacity: 0; border: 0; background: transparent; color: rgba(0, 0, 0, .45); font-size: 1.1rem; padding: 6px; }
.item:hover .del, .item:focus-within .del { opacity: 1; }
@media (hover: none) { .item .del { opacity: .45; } }
.item.done textarea { text-decoration: line-through; color: rgba(0, 0, 0, .45); }
.item.ghost { background: rgba(255, 255, 255, .7); border-radius: 8px; }
.item.chosen { box-shadow: 0 2px 8px rgba(0, 0, 0, .18); background: rgba(255, 255, 255, .85); border-radius: 8px; }

.bodytext {
  display: block; width: calc(100% - 24px); margin: 10px 12px; min-height: 60vh;
  border: 0; outline: none; resize: none; background: transparent;
  font-size: 1.05rem; line-height: 1.6;
}

/* ---- 색상·메뉴 ---- */
.sheet {
  position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, .25);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet .panel {
  background: #fff; width: 100%; max-width: 480px; border-radius: 16px 16px 0 0;
  padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .15); }
.swatch.on { border-color: #333; }
.menu button { display: block; width: 100%; padding: 12px; border: 0; background: transparent; text-align: left; border-radius: 8px; font-size: 1rem; }
.menu button:hover { background: #f1f1f1; }
.menu .danger { color: #c0392b; }

@media (min-width: 700px) {
  .memo-wrap { max-width: 640px; margin: 0 auto; }
}

/* ---- PC 낱장 창: 위 막대를 잡고 끌어 옮긴다 ---- */
.desk .memo .topbar { -webkit-app-region: drag; padding: 6px 8px; }
.desk .memo .topbar input, .desk .memo .topbar button, .desk .memo .topbar .status { -webkit-app-region: no-drag; }
.desk .memo .topbar .status { display: none; }
.desk .memo .topbar .iconbtn { min-width: 32px; height: 32px; font-size: 1rem; }
.pin { opacity: .35; filter: grayscale(1); }
.pin.on { opacity: 1; filter: none; }

/* ---- 회의 메모 ---- */
.newrow { flex-wrap: wrap; }
.recbar { display: flex; align-items: center; gap: 10px; margin: 10px 12px 0; }
.recbtn {
  border: 0; border-radius: 999px; padding: 10px 18px; font-size: 1rem; font-weight: 700;
  background: #c62828; color: #fff; white-space: nowrap;
}
.recbtn.on { background: #333; animation: recpulse 1.6s ease-in-out infinite; }
.recbtn:disabled { opacity: .5; animation: none; }
@keyframes recpulse { 50% { box-shadow: 0 0 0 6px rgba(198, 40, 40, .25); } }
.recinfo { font-size: .85rem; color: var(--muted); }
.recs { margin: 18px 12px 40px; }
.reccard { background: rgba(255, 255, 255, .55); border-radius: 12px; padding: 12px 14px; margin-top: 8px; }
.rechead { font-weight: 700; font-size: .95rem; }
.recbtns { display: flex; gap: 8px; margin: 8px 0; }
.recbtns button { border: 1px solid rgba(0, 0, 0, .15); background: #fff; border-radius: 8px; padding: 6px 12px; font-size: .9rem; }
.recdel { margin-left: auto; color: var(--muted); }
.reccard audio { width: 100%; margin: 4px 0 8px; }
.recsum { white-space: pre-wrap; line-height: 1.6; margin: 6px 0; }
.rectext { white-space: pre-wrap; font: inherit; font-size: .9rem; line-height: 1.6; color: #444; margin: 8px 0 0; max-height: 50vh; overflow: auto; }
.reccard details summary { cursor: pointer; color: var(--accent); font-size: .9rem; margin-top: 6px; }
