:root,
body[data-theme="pink"] {
  --bg: #fdf7f1;
  --ink: #3a2e2a;
  --line: #e3bcc6;
  --line-strong: #d39fae;
  --accent: #d98ca0;
  --accent-soft: #f3d6dd;
  --label-bg: #faeaef;
  --label-ink: #8a3e54;
  --done-ink: #8a6772;
  --label-bg-done: #eccfd6;
}

body[data-theme="blue"] {
  --bg: #f4f8fc;
  --line: #b9d2ea;
  --line-strong: #8eb4dd;
  --accent: #7aa8d6;
  --accent-soft: #d6e6f4;
  --label-bg: #ecf3fa;
  --label-ink: #2f567a;
  --done-ink: #6c7d8e;
  --label-bg-done: #c5d8ea;
}

body[data-theme="green"] {
  --bg: #f4faf3;
  --line: #b9d6bd;
  --line-strong: #92bf99;
  --accent: #7eb288;
  --accent-soft: #d8ead9;
  --label-bg: #ebf4ec;
  --label-ink: #3a6741;
  --done-ink: #6f8073;
  --label-bg-done: #c5dec7;
}

body[data-theme="orange"] {
  --bg: #fdf6ee;
  --line: #e8c8a8;
  --line-strong: #d6a474;
  --accent: #e0a374;
  --accent-soft: #f4dcc6;
  --label-bg: #faecd9;
  --label-ink: #7d4a23;
  --done-ink: #8a7560;
  --label-bg-done: #ebcfae;
}

body[data-theme="neutral"] {
  --bg: #f8f5f0;
  --line: #d4c8b9;
  --line-strong: #b8a892;
  --accent: #9c8b78;
  --accent-soft: #e2d8cc;
  --label-bg: #f0e8dc;
  --label-ink: #4a3e30;
  --done-ink: #80766a;
  --label-bg-done: #d6cab8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Georgia", "Iowan Old Style", serif;
  overflow-x: hidden;
}

.sprig {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  opacity: 0.85;
  overflow: visible;
}

.theme-picker {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 5;
  display: inline-flex;
  gap: 6px;
  padding: 5px 7px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  backdrop-filter: blur(4px);
  opacity: 0.6;
  transition: opacity 0.15s ease;
}

.theme-picker:hover { opacity: 1; }

.theme-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 0, 0, 0.12);
  cursor: pointer;
  padding: 0;
  transition: transform 0.12s ease, border-color 0.12s ease;
}

.theme-swatch:hover { transform: scale(1.18); }
.theme-swatch.active {
  border-color: rgba(0, 0, 0, 0.45);
  transform: scale(1.18);
}

.theme-swatch[data-theme="pink"]    { background: #d98ca0; }
.theme-swatch[data-theme="blue"]    { background: #7aa8d6; }
.theme-swatch[data-theme="green"]   { background: #7eb288; }
.theme-swatch[data-theme="orange"]  { background: #e0a374; }
.theme-swatch[data-theme="neutral"] { background: #9c8b78; }

.sprig-1  { top: 4%;    left: 3%;   width: 70px; height: 70px; transform: rotate(-15deg); }
.sprig-2  { top: 8%;    right: 4%;  width: 60px; height: 60px; transform: rotate(20deg); }
.sprig-3  { top: 38%;   left: 2%;   width: 44px; height: 44px; transform: rotate(-30deg); }
.sprig-4  { top: 55%;   right: 3%;  width: 56px; height: 56px; transform: rotate(35deg); }
.sprig-5  { bottom: 6%; left: 5%;   width: 64px; height: 64px; transform: rotate(25deg); }
.sprig-6  { bottom: 10%; right: 6%; width: 46px; height: 46px; transform: rotate(-20deg); }
.sprig-7  { top: 22%;   left: 7%;   width: 38px; height: 38px; transform: rotate(60deg); }
.sprig-8  { bottom: 30%; right: 9%; width: 36px; height: 36px; transform: rotate(-50deg); }
.sprig-9  { top: 18%;   right: 11%; width: 38px; height: 38px; transform: rotate(15deg); }
.sprig-10 { top: 72%;   left: 4%;   width: 42px; height: 42px; transform: rotate(-25deg); }
.sprig-11 { top: 50%;   left: 9%;   width: 30px; height: 30px; transform: rotate(45deg); }
.sprig-12 { top: 78%;   right: 10%; width: 38px; height: 38px; transform: rotate(-10deg); }
.sprig-13 { top: 14%;   left: 13%;  width: 30px; height: 30px; transform: rotate(-40deg); }
.sprig-14 { bottom: 22%; left: 13%; width: 38px; height: 38px; transform: rotate(50deg); }
.sprig-15 { top: 36%;   right: 13%; width: 28px; height: 28px; transform: rotate(-15deg); }
.sprig-16 { bottom: 18%; right: 14%; width: 34px; height: 34px; transform: rotate(30deg); }

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 32px;
  padding: 48px 32px;
}

.grid-area {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.grid-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 14px;
}

.grid-controls button {
  background: white;
  color: var(--accent);
  border: 1.5px solid var(--line-strong);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  padding: 0;
  font: inherit;
  font-size: 18px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

.grid-controls button:hover {
  background: var(--accent);
  color: white;
  transform: scale(1.06);
}

.grid {
  border-collapse: separate;
  border-spacing: 0;
  background: white;
  border: 2px solid var(--line-strong);
  border-radius: 10px;
  overflow: hidden;
  table-layout: fixed;
  box-shadow: 0 4px 16px rgba(217, 140, 160, 0.12);
}

.grid col.col-check { width: 44px; }

.grid td {
  border: 1px solid var(--line);
  vertical-align: top;
  padding: 0;
  position: relative;
}

.grid td.cell-check {
  vertical-align: middle;
  text-align: center;
  background: var(--label-bg);
}

.grid td.cell-check input {
  appearance: none;
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--line-strong);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  vertical-align: middle;
  position: relative;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.grid td.cell-check input:hover {
  border-color: var(--accent);
}

.grid td.cell-check input:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.grid td.cell-check input:checked::after {
  content: "";
  position: absolute;
  left: 5px;
  top: 1px;
  width: 6px;
  height: 11px;
  border: solid white;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg);
}

.grid td.cell-text {
  vertical-align: top;
  padding: 0;
}

.grid td.cell-text .cell-editor {
  display: block;
  width: 100%;
  min-height: var(--row-h, 56px);
  padding: 10px 14px;
  outline: none;
  font-size: 16px;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  text-align: left;
  cursor: text;
}

.grid td.cell-label {
  font-weight: 600;
  background: var(--label-bg);
  color: var(--label-ink);
}

.grid tr.done td {
  background: var(--accent-soft);
}

.grid tr.done td.cell-label {
  background: var(--label-bg-done);
}

.grid tr.done td.cell-text {
  text-decoration: line-through;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 2px;
  color: var(--done-ink);
}

.grid tr.done td.cell-check {
  background: var(--accent-soft);
}

.col-resizer {
  position: absolute;
  top: 0;
  right: 0;
  width: 9px;
  height: 100%;
  cursor: col-resize;
  z-index: 2;
  user-select: none;
}

.row-resizer {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: 9px;
  cursor: row-resize;
  z-index: 2;
  user-select: none;
}

.col-resizer::after,
.row-resizer::after {
  content: "";
  position: absolute;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.1s ease;
}

.col-resizer::after {
  top: 0;
  bottom: 0;
  right: 3px;
  width: 2px;
}

.row-resizer::after {
  left: 0;
  right: 0;
  bottom: 3px;
  height: 2px;
}

.col-resizer:hover::after,
.row-resizer:hover::after { opacity: 0.5; }

.resizing .col-resizer.active::after,
.resizing .row-resizer.active::after { opacity: 0.8; }

body.resizing {
  cursor: col-resize;
  user-select: none;
}
body.resizing.row { cursor: row-resize; }

.message-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding-top: 8px;
}

.message-input-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  cursor: text;
  width: 160px;
  justify-content: flex-start;
}

.message-input-wrap:focus-within {
  border-color: var(--accent);
}

.message-input-icon {
  color: var(--accent);
  font-size: 16px;
  line-height: 1;
}

.message-input {
  font: inherit;
  font-size: 14px;
  border: none;
  outline: none;
  background: transparent;
  color: transparent;
  flex: 1;
  min-width: 0;
  padding: 0;
}

.message-input-wrap:focus-within .message-input {
  color: var(--ink);
}

.vertical-message {
  writing-mode: vertical-rl;
  text-orientation: upright;
  letter-spacing: 6px;
  font-size: 36px;
  font-weight: 600;
  color: var(--accent);
  min-height: 240px;
  min-width: 56px;
  outline: none;
  padding: 12px 8px;
  border-left: 2px dashed var(--accent-soft);
}

.vertical-message:empty::before {
  content: attr(data-placeholder);
  color: var(--accent-soft);
  font-style: italic;
}

@media (max-width: 720px) {
  .page {
    flex-direction: column;
    align-items: center;
    padding: 32px 16px;
  }
  .sprig { transform-origin: center; opacity: 0.7; }
  .sprig-1, .sprig-2, .sprig-4, .sprig-5,
  .sprig-9, .sprig-10, .sprig-12, .sprig-14 { width: 40px; height: 40px; }
  .sprig-3, .sprig-6, .sprig-11, .sprig-13,
  .sprig-15, .sprig-16 { width: 28px; height: 28px; }
  .sprig-7, .sprig-8 { width: 26px; height: 26px; }
  .vertical-message { font-size: 28px; min-height: 160px; }
}
