@import url('https://fonts.googleapis.com/css2?family=Kiwi+Maru:wght@400;500&family=Noto+Sans+JP:wght@400;500;600;700&display=swap');

:root {
  font-family: "Noto Sans JP", system-ui, sans-serif;
  color: #34312d;
  background: #f4efe6;
  font-synthesis: none;
  --header-height: 92px;
  --filter-height: 52px;
  --project-height: 58px;
  --footer-height: 46px;
  --note-width: 220px;
  --note-height: 218px;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-width: 320px; min-height: 100%; }

body {
  min-height: 100vh;
  overflow: hidden;
  background: #f4efe6;
}

button, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 0 42px;
  background: rgba(250, 247, 241, .96);
  border-bottom: 1px solid #ded7cc;
  position: relative;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 14px; flex: 0 0 auto; }
.brand-mark {
  width: 35px; height: 35px; display: block; background: #f5c84c;
  border-radius: 2px 2px 8px 2px; transform: rotate(-4deg);
  box-shadow: 0 5px 12px rgba(102, 77, 24, .16);
  position: relative;
}
.brand-mark::after {
  content: ""; position: absolute; right: 0; bottom: 0;
  border-style: solid; border-width: 0 0 8px 8px;
  border-color: transparent transparent #dcae32 transparent;
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: .06em; font-weight: 700; }
.brand p { margin: 4px 0 0; font-size: 11px; color: #8b8379; letter-spacing: .12em; }
.search-box {
  width: min(300px, 25vw); height: 42px; display: flex; align-items: center; gap: 10px;
  margin-left: auto; padding: 0 13px; border: 1px solid #d9d1c5; border-radius: 22px;
  background: #fffdfa; color: #91887c; transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: #8e9b90; box-shadow: 0 0 0 3px rgba(91, 112, 96, .12); }
.search-icon { width: 14px; height: 14px; border: 1.8px solid currentColor; border-radius: 50%; position: relative; flex: 0 0 auto; }
.search-icon::after { content: ""; position: absolute; width: 6px; height: 1.8px; right: -5px; bottom: -2px; background: currentColor; transform: rotate(45deg); border-radius: 2px; }
.search-box input {
  width: 100%; min-width: 0; border: 0; outline: 0; padding: 0; background: transparent;
  color: #454039; font-size: 13px; appearance: none;
}
.search-box input::placeholder { color: #9b9388; }
.search-box input::-webkit-search-cancel-button { cursor: pointer; }
.header-actions { display: flex; align-items: center; gap: 25px; flex: 0 0 auto; }
.theme-toggle {
  width: 38px; height: 38px; display: grid; place-items: center; flex: 0 0 auto;
  border: 1px solid #d8d0c5; border-radius: 50%; background: #fffdfa; color: #5e5a53;
  font-size: 19px; cursor: pointer; box-shadow: 0 2px 7px rgba(62,52,40,.08);
  transition: background .18s, color .18s, transform .18s, border-color .18s;
}
.theme-toggle:hover { background: #f0eadf; transform: translateY(-1px) rotate(-8deg); }
.theme-toggle:focus-visible { outline: 3px solid #3276aa; outline-offset: 2px; }
.color-picker { display: flex; align-items: center; gap: 12px; }
.color-chip {
  width: 25px; height: 25px; padding: 0; border: 2px solid transparent;
  border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(69, 61, 49, .07);
}
.color-chip[data-color="yellow"] { background: #f6d96c; }
.color-chip[data-color="pink"] { background: #f3acb5; }
.color-chip[data-color="blue"] { background: #a9cee7; }
.color-chip[data-color="green"] { background: #b9d79c; }
.color-chip.is-active { border-color: #fff; outline: 2px solid #4a4640; transform: scale(1.08); }
.color-chip:focus-visible, .add-button:focus-visible, .delete-button:focus-visible { outline: 3px solid #3276aa; outline-offset: 3px; }
.add-button {
  min-height: 44px; border: 0; border-radius: 8px; padding: 0 19px;
  color: #fff; background: #3e4b42; font-weight: 600; letter-spacing: .02em;
  cursor: pointer; box-shadow: 0 4px 12px rgba(49, 63, 53, .18);
  transition: transform .15s, background .15s;
}
.add-button span { font-size: 20px; margin-right: 5px; font-weight: 400; }
.add-button:hover { background: #2e3931; transform: translateY(-1px); }
.add-button:active { transform: translateY(1px); }

.project-bar {
  height: var(--project-height); display: flex; align-items: center; gap: 16px; padding: 0 42px;
  background: #f5f0e7; border-bottom: 1px solid #dcd4c8; position: relative; z-index: 16;
}
.project-heading { display: flex; flex-direction: column; flex: 0 0 auto; padding-right: 17px; border-right: 1px solid #d8d0c4; }
.project-heading span { color: #a0998e; font-size: 8px; font-weight: 700; letter-spacing: .15em; }
.project-heading strong { margin-top: 2px; font-size: 12px; }
.project-list { display: flex; align-items: center; gap: 7px; min-width: 0; flex: 1; overflow-x: auto; scrollbar-width: none; }
.project-list::-webkit-scrollbar { display: none; }
.project-list button, .project-actions button {
  height: 34px; border: 1px solid transparent; border-radius: 8px; padding: 0 13px; white-space: nowrap;
  background: transparent; color: #777067; font-size: 11px; font-weight: 600; cursor: pointer;
}
.project-list button { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }
.project-list button:hover, .project-actions button:hover { background: rgba(255,255,255,.62); }
.project-list button.is-active { background: #fff; color: #435047; border-color: #d8d1c6; box-shadow: 0 2px 7px rgba(65,55,42,.09); }
.project-actions { display: flex; align-items: center; gap: 3px; flex: 0 0 auto; }
.project-actions .add-project { color: #fff; background: #6b796e; padding: 0 15px; }
.project-actions .add-project:hover { background: #536258; }
.project-list button:focus-visible, .project-actions button:focus-visible { outline: 3px solid #3276aa; outline-offset: 2px; }

.status-filter {
  height: var(--filter-height); display: flex; align-items: center; justify-content: center;
  background: #faf7f1; border-bottom: 1px solid #ded7cc; position: relative; z-index: 15;
}
.filter-options { display: flex; align-items: center; gap: 4px; }
.filter-options button {
  min-width: 82px; height: 34px; padding: 0 16px; border: 0; border-radius: 17px;
  background: transparent; color: #7d756b; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: color .15s, background .15s, box-shadow .15s;
}
.filter-options button:hover { background: #eee8de; }
.filter-options button.is-active { color: #fff; background: #536257; box-shadow: 0 3px 8px rgba(50, 65, 54, .16); }
.filter-options button:focus-visible, .arrange-button:focus-visible { outline: 3px solid #3276aa; outline-offset: 2px; }
.arrange-button {
  position: absolute; right: 42px; height: 34px; padding: 0 14px; border: 1px solid #d8d0c5;
  border-radius: 8px; background: #fff; color: #625c54; font-size: 11px; font-weight: 700; cursor: pointer;
  box-shadow: 0 2px 6px rgba(62,52,40,.06); transition: background .15s, transform .15s;
}
.arrange-button span { margin-right: 5px; font-size: 14px; }
.arrange-button:hover { background: #f1ece3; transform: translateY(-1px); }

.board {
  position: relative;
  height: calc(100vh - var(--header-height) - var(--project-height) - var(--filter-height) - var(--footer-height));
  min-height: 300px;
  overflow: auto;
  background-color: #f3eee5;
  background-image: radial-gradient(circle, rgba(117, 103, 83, .2) 1px, transparent 1.2px);
  background-size: 24px 24px;
  background-position: 11px 11px;
  overscroll-behavior: none;
}
.board::before {
  content: ""; position: fixed; inset: calc(var(--header-height) + var(--project-height) + var(--filter-height)) 0 var(--footer-height); pointer-events: none;
  box-shadow: inset 0 18px 28px -30px rgba(55, 45, 30, .5);
}
.notes-layer { position: relative; width: 100%; min-width: 100%; min-height: 100%; }
.empty-state {
  position: absolute; z-index: 0; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: #8d857a; pointer-events: none;
  transform: translateY(-12px);
}
.empty-note {
  width: 78px; height: 75px; display: grid; place-items: center; margin-bottom: 23px;
  background: rgba(231, 219, 197, .7); border: 1px dashed #bdb2a2; transform: rotate(-3deg);
  box-shadow: 5px 7px 0 rgba(186, 171, 148, .14);
}
.empty-note span { font-size: 31px; font-weight: 300; color: #a49a8c; }
.empty-state h2 { font-family: "Kiwi Maru", serif; font-size: 18px; font-weight: 500; margin: 0 0 9px; color: #787066; }
.empty-state p { font-size: 12px; margin: 0; letter-spacing: .04em; }
.empty-state.is-hidden { display: none; }
.empty-state.is-search-empty .empty-note { transform: rotate(2deg); }

.completion-zone {
  position: absolute; z-index: 2; top: 22px; right: 22px; bottom: 22px; width: 252px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  border: 2px dashed rgba(91, 112, 96, .36); border-radius: 18px;
  background: rgba(238, 242, 233, .66); color: #677368; text-align: center; pointer-events: none;
  transition: background .18s, border-color .18s, transform .18s, box-shadow .18s;
}
.completion-zone.is-over { background: rgba(213, 231, 202, .94); border-color: #688161; transform: scale(1.015); box-shadow: inset 0 0 0 4px rgba(255,255,255,.45), 0 8px 22px rgba(68, 89, 70, .12); }
.completion-zone-icon { width: 48px; height: 48px; display: grid; place-items: center; border-radius: 50%; background: #d7e4ce; color: #557053; font-size: 24px; font-weight: 700; }
.completion-zone h2 { margin: 0 0 5px; font-family: "Kiwi Maru", serif; font-size: 17px; font-weight: 500; }
.completion-zone p { margin: 0; font-size: 11px; color: #8b968b; }
.completed-count { position: absolute; top: 14px; right: 14px; min-width: 27px; height: 27px; padding: 0 7px; display: grid; place-items: center; border-radius: 14px; background: #fff; color: #647064; font-size: 11px; font-weight: 700; box-shadow: 0 2px 7px rgba(64,78,66,.1); }

.note {
  position: absolute; width: var(--note-width); height: var(--note-height);
  border-radius: 3px 3px 10px 3px; overflow: hidden;
  --note-rotate: -0.8deg;
  transform: rotate(var(--note-rotate));
  transform-origin: 50% 8%;
  box-shadow:
    1px 3px 4px rgba(72, 57, 36, .12),
    7px 12px 20px rgba(72, 57, 36, .16);
  transition: box-shadow .18s, transform .18s;
  animation: note-in .22s ease-out both;
  touch-action: none;
}
.note:nth-child(4n + 2) { --note-rotate: 0.65deg; }
.note:nth-child(4n + 3) { --note-rotate: -0.35deg; }
.note:nth-child(4n + 4) { --note-rotate: 0.95deg; }
.note.is-filtered-out { display: none; }
.note.is-arranging { transition: left .25s ease, top .25s ease, box-shadow .18s, transform .18s; }
.note.is-complete { filter: saturate(.58); opacity: .82; }
.note.is-complete .note-text { text-decoration: line-through; text-decoration-thickness: 1.5px; text-decoration-color: rgba(65,77,65,.55); color: #666a61; }
.note[data-color="yellow"] { background: #f8de79; --fold: #ddbc4d; }
.note[data-color="pink"] { background: #f5bcc3; --fold: #dc939e; }
.note[data-color="blue"] { background: #b9d8eb; --fold: #8ebbd6; }
.note[data-color="green"] { background: #c6dea9; --fold: #9fc77b; }
.note::after {
  content: ""; position: absolute; right: 0; bottom: 0; pointer-events: none;
  border-style: solid; border-width: 0 0 13px 13px;
  border-color: transparent transparent var(--fold) transparent;
}
.note.is-dragging { z-index: 1000 !important; transform: rotate(var(--note-rotate)) scale(1.02); box-shadow: 2px 20px 32px rgba(55, 45, 30, .22); transition: box-shadow .18s, transform .18s; }
.note-header {
  height: 46px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 9px 0 15px; cursor: grab; user-select: none;
  border-bottom: 1px solid rgba(77, 64, 39, .08);
}
.note-header:active { cursor: grabbing; }
.grip { color: rgba(64, 55, 41, .38); font-size: 17px; letter-spacing: 2px; line-height: 1; }
.delete-button {
  width: 35px; height: 35px; border: 0; border-radius: 50%; background: transparent;
  color: rgba(52, 45, 35, .52); font-size: 20px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; transition: color .15s, background .15s;
}
.note-actions { display: flex; align-items: center; gap: 1px; }
.complete-button {
  width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid rgba(64,74,59,.24);
  border-radius: 50%; background: rgba(255,255,255,.22); color: rgba(58,68,55,.52);
  font-size: 16px; font-weight: 700; cursor: pointer; transition: color .15s, background .15s, border-color .15s, transform .15s;
}
.complete-button:hover { transform: scale(1.06); background: rgba(255,255,255,.46); }
.complete-button[aria-pressed="true"] { color: #fff; background: #627b5f; border-color: #627b5f; }
.complete-button:focus-visible { outline: 3px solid #3276aa; outline-offset: 2px; }
.delete-button:hover { background: rgba(255,255,255,.35); color: #704645; }
.note-text {
  display: block; width: 100%; height: calc(100% - 46px); resize: none; border: 0; outline: 0;
  padding: 15px 17px 19px; background: transparent; color: #443e34;
  font-family: "Kiwi Maru", serif; font-size: 16px; line-height: 1.75; overflow: auto;
  touch-action: pan-y;
}
.note-text::placeholder { color: rgba(68, 62, 52, .43); }

.app-footer {
  height: var(--footer-height); display: flex; align-items: center; justify-content: space-between;
  padding: 0 42px; background: #faf7f1; border-top: 1px solid #ded7cc;
  color: #8a8278; font-size: 11px; letter-spacing: .04em;
}
.app-footer p { margin: 0; }
.divider { margin: 0 9px; }
.drag-hint { color: #a0988d; }

.project-dialog {
  width: min(420px, calc(100vw - 32px)); border: 0; border-radius: 18px; padding: 0;
  background: #fbf8f2; color: #3f3b35; box-shadow: 0 24px 70px rgba(48,40,30,.28);
}
.project-dialog::backdrop { background: rgba(52,48,42,.36); backdrop-filter: blur(2px); }
.project-dialog form { padding: 30px; }
.dialog-mark { width: 34px; height: 34px; margin-bottom: 18px; border-radius: 3px 3px 8px 3px; background: #f5c84c; transform: rotate(-4deg); box-shadow: 3px 5px 10px rgba(80,61,28,.14); }
.project-dialog h2 { margin: 0 0 8px; font-size: 19px; }
.project-dialog p { margin: 0 0 22px; color: #7e776d; font-size: 12px; line-height: 1.7; }
.project-dialog label { display: block; margin-bottom: 7px; font-size: 11px; font-weight: 700; }
.project-dialog input { width: 100%; height: 45px; border: 1px solid #d7cfc2; border-radius: 9px; padding: 0 13px; outline: 0; background: #fff; color: #3f3b35; }
.project-dialog input:focus { border-color: #7b8c7e; box-shadow: 0 0 0 3px rgba(91,112,96,.12); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 25px; }
.dialog-actions button { height: 40px; border: 0; border-radius: 8px; padding: 0 17px; background: #eee8de; color: #655e55; font-size: 12px; font-weight: 700; cursor: pointer; }
.dialog-actions .dialog-primary { color: #fff; background: #536257; }
.dialog-actions .dialog-primary.is-danger { background: #a8524f; }

@keyframes note-in {
  from { opacity: 0; transform: translateY(7px) rotate(calc(var(--note-rotate) - .7deg)); }
  to { opacity: 1; transform: rotate(var(--note-rotate)); }
}

@media (max-width: 767px) {
  :root { --header-height: 132px; --footer-height: 70px; --note-width: 170px; --note-height: 184px; }
  .app-header { padding: 12px 16px; gap: 11px 12px; display: grid; grid-template-columns: 1fr auto; grid-template-rows: 42px 44px; }
  .brand { gap: 9px; }
  .brand-mark { width: 29px; height: 29px; }
  .brand h1 { font-size: 16px; }
  .brand p { display: none; }
  .search-box { grid-column: 1 / -1; grid-row: 2; width: 100%; height: 44px; margin: 0; }
  .header-actions { gap: 8px; }
  .theme-toggle { width: 34px; height: 34px; font-size: 17px; }
  .color-picker { gap: 7px; }
  .color-chip { width: 24px; height: 24px; }
  .add-button { position: fixed; z-index: 50; right: 16px; bottom: 13px; min-width: 142px; min-height: 48px; border-radius: 24px; }
  .board { min-height: 260px; }
  .project-bar { padding: 0 12px; gap: 8px; }
  .project-heading { display: none; }
  .project-list { gap: 5px; }
  .project-list button { padding: 0 11px; max-width: 130px; }
  .project-actions { gap: 1px; }
  .project-actions button { width: 34px; padding: 0; font-size: 0; }
  .project-actions button::before { font-size: 15px; }
  #rename-project::before { content: "✎"; }
  #delete-project::before { content: "×"; }
  .project-actions .add-project { width: 38px; padding: 0; }
  .project-actions .add-project span { font-size: 18px; }
  .status-filter { padding: 0 10px; }
  .filter-options { width: calc(100% - 76px); margin-right: auto; }
  .filter-options button { flex: 1; max-width: 112px; min-width: 0; padding: 0 6px; }
  .arrange-button { right: 10px; width: 64px; padding: 0; }
  .completion-zone { position: fixed; z-index: 12; top: auto; left: 14px; right: 174px; bottom: 9px; width: auto; height: 52px; padding: 0 12px; flex-direction: row; justify-content: flex-start; gap: 8px; border-radius: 13px; }
  .completion-zone-icon { width: 31px; height: 31px; flex: 0 0 auto; font-size: 16px; }
  .completion-zone h2 { margin: 0; font-family: inherit; font-size: 11px; }
  .completion-zone p { display: none; }
  .completed-count { position: static; min-width: 23px; height: 23px; margin-left: auto; padding: 0 6px; }
  .note-header { height: 45px; }
  .note-text { height: calc(100% - 45px); padding: 11px 13px 15px; font-size: 15px; line-height: 1.65; }
  .app-footer { padding: 0 174px 0 16px; justify-content: flex-start; }
  .app-footer p { line-height: 1.55; }
  .divider, .drag-hint { display: none; }
}

@media (max-width: 410px) {
  .app-header { padding: 0 12px; }
  .brand-mark { display: none; }
  .color-picker { gap: 6px; }
  .color-chip { width: 23px; height: 23px; }
}

@media (min-width: 768px) and (max-width: 1100px) {
  .app-header, .app-footer { padding-left: 28px; padding-right: 28px; }
  .header-actions { gap: 14px; }
}

[data-theme="dark"] { color-scheme: dark; background: #242724; }
[data-theme="dark"] body { color: #e8e5dd; background: #242724; }
[data-theme="dark"] .app-header { background: rgba(35, 38, 35, .97); border-bottom-color: #464b46; }
[data-theme="dark"] .brand p { color: #9da39d; }
[data-theme="dark"] .search-box { background: #2d312e; border-color: #4b514c; color: #a8afa8; }
[data-theme="dark"] .search-box:focus-within { border-color: #839887; box-shadow: 0 0 0 3px rgba(128, 157, 134, .16); }
[data-theme="dark"] .search-box input { color: #eeece6; }
[data-theme="dark"] .search-box input::placeholder { color: #888f89; }
[data-theme="dark"] .theme-toggle { background: #353a36; border-color: #505650; color: #f3cd67; box-shadow: 0 2px 8px rgba(0,0,0,.22); }
[data-theme="dark"] .theme-toggle:hover { background: #414741; }
[data-theme="dark"] .color-chip.is-active { border-color: #292d2a; outline-color: #e4e0d7; }
[data-theme="dark"] .add-button { background: #6f8875; box-shadow: 0 4px 14px rgba(0,0,0,.24); }
[data-theme="dark"] .add-button:hover { background: #7d987f; }
[data-theme="dark"] .project-bar { background: #292d2a; border-bottom-color: #454a45; }
[data-theme="dark"] .project-heading { border-right-color: #4b504b; }
[data-theme="dark"] .project-heading span { color: #828982; }
[data-theme="dark"] .project-list button,
[data-theme="dark"] .project-actions button { color: #b5bab5; }
[data-theme="dark"] .project-list button:hover,
[data-theme="dark"] .project-actions button:hover { background: rgba(255,255,255,.07); }
[data-theme="dark"] .project-list button.is-active { background: #3a403b; color: #f1efe9; border-color: #596059; box-shadow: 0 2px 8px rgba(0,0,0,.18); }
[data-theme="dark"] .project-actions .add-project { color: #fff; background: #617566; }
[data-theme="dark"] .status-filter { background: #252925; border-bottom-color: #454a45; }
[data-theme="dark"] .filter-options button { color: #afb5af; }
[data-theme="dark"] .filter-options button:hover { background: #363b37; }
[data-theme="dark"] .filter-options button.is-active { color: #fff; background: #667d6b; }
[data-theme="dark"] .arrange-button { background: #343935; border-color: #505650; color: #d8dbd7; box-shadow: 0 2px 7px rgba(0,0,0,.16); }
[data-theme="dark"] .arrange-button:hover { background: #414741; }
[data-theme="dark"] .board {
  background-color: #202320;
  background-image: radial-gradient(circle, rgba(190, 200, 190, .16) 1px, transparent 1.2px);
}
[data-theme="dark"] .board::before { box-shadow: inset 0 18px 28px -30px rgba(0,0,0,.9); }
[data-theme="dark"] .empty-state { color: #8f968f; }
[data-theme="dark"] .empty-note { background: rgba(65, 70, 65, .68); border-color: #676e67; box-shadow: 5px 7px 0 rgba(0,0,0,.16); }
[data-theme="dark"] .empty-note span,
[data-theme="dark"] .empty-state h2 { color: #aab0aa; }
[data-theme="dark"] .completion-zone { background: rgba(48, 57, 49, .72); border-color: rgba(137, 164, 141, .4); color: #b4c1b5; }
[data-theme="dark"] .completion-zone.is-over { background: rgba(67, 91, 70, .92); border-color: #91ad94; }
[data-theme="dark"] .completion-zone-icon { background: #465a49; color: #cee0cf; }
[data-theme="dark"] .completion-zone p { color: #8e9d90; }
[data-theme="dark"] .completed-count { background: #353d36; color: #d5ded5; box-shadow: 0 2px 7px rgba(0,0,0,.18); }
[data-theme="dark"] .app-footer { background: #252925; border-top-color: #454a45; color: #969d97; }
[data-theme="dark"] .drag-hint { color: #7f8780; }
[data-theme="dark"] .project-dialog { background: #2c302d; color: #ece9e2; box-shadow: 0 24px 70px rgba(0,0,0,.5); }
[data-theme="dark"] .project-dialog::backdrop { background: rgba(9,11,9,.64); }
[data-theme="dark"] .project-dialog p { color: #a7ada7; }
[data-theme="dark"] .project-dialog input { background: #222522; border-color: #505650; color: #efede7; }
[data-theme="dark"] .dialog-actions button { background: #414641; color: #d7dbd7; }
[data-theme="dark"] .dialog-actions .dialog-primary { color: #fff; background: #667d6b; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
