/* デザインの正本: ./DESIGN.md */
:root {
  --text: #2C2C2B;
  --text-2: #7D7A75;
  --text-3: #A6A299;
  --bg: #FFFFFF;
  --sidebar: #F8F8F7;
  --input-bg: #F7F7F5;
  --divider: #EDEDEC;
  --hover: rgba(55, 53, 47, .06);
  --active: rgba(55, 53, 47, .09);
  --blue: #2783DE;
  --blue-hover: #1F70C1;
  --blue-text: #337EA9;
  --selected: rgba(35, 131, 226, .10);
  --focus: rgba(35, 131, 226, .60);
  --red-text: #D44C47;
  --shadow: 0 0 0 1px rgba(15, 15, 15, .05), 0 3px 6px rgba(15, 15, 15, .1), 0 9px 24px rgba(15, 15, 15, .2);
}

* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font: 14px/1.5 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Source Han Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, Helvetica, Arial, sans-serif; }
body { min-width: 0; margin: 0; overflow-x: hidden; }
body.is-dragging, body.is-dragging * { cursor: grabbing !important; user-select: none; }
button, input, select, textarea { font: inherit; -webkit-tap-highlight-color: transparent; }
button { padding: 0; border: 0; background: none; color: inherit; cursor: pointer; }
button:disabled, input:disabled, select:disabled { cursor: default; opacity: .55; }
[hidden] { display: none !important; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.icon-library { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.65; stroke-linecap: round; stroke-linejoin: round; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 80; padding: 8px 12px; border-radius: 6px; background: var(--blue); color: #fff; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100dvh; }
.sidebar { position: sticky; top: 0; z-index: 10; display: flex; flex-direction: column; height: 100dvh; padding: 18px 12px 16px; overflow-y: auto; border-right: 1px solid var(--divider); background: var(--sidebar); }
.workspace { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px; margin: 0 0 14px; font-size: 14px; }
.workspace strong { font-weight: 600; }
.workspace-icon { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 6px; background: #EDF3EC; color: #448361; }
.workspace-icon .icon { width: 16px; height: 16px; }
.demo-label { padding: 1px 4px; border-radius: 4px; background: #F0EFED; color: var(--text-2); font-size: 9px; font-weight: 600; letter-spacing: .07em; }
.nav-stack { display: grid; gap: 2px; }
.nav-button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 4px 8px; border-radius: 6px; color: #5F5E5B; text-align: left; }
.nav-button .icon { width: 18px; height: 18px; color: var(--text-3); }
.nav-button[data-view="inbox"] .icon, .nav-button[data-view="next"] .icon, .nav-button[data-view="remind"] .icon, .nav-button[data-view="waiting"] .icon { color: var(--red-text); }
.nav-button[data-view="project"] .icon { color: #CB912F; }
.nav-button[data-view="wishlist"] .icon { color: #448361; }
.nav-button[data-view="completed"] .icon { color: var(--blue); }
.nav-button:hover { background: var(--hover); }
.nav-button[aria-current="page"] { background: var(--active); color: var(--text); font-weight: 500; }
.nav-label { min-width: 0; flex: 1; }
.nav-count { color: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.sidebar-footer { padding: 20px 8px 0; margin-top: auto; color: var(--text-2); font-size: 12px; }
.sidebar-footer p + p { margin-top: 2px; }
.text-button { min-height: 28px; color: var(--blue-text); text-align: left; }
.text-button:hover { text-decoration: underline; }

.main { min-width: 0; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 48px; border-bottom: 1px solid var(--divider); }
.breadcrumb { display: flex; align-items: center; min-width: 0; flex: 1; color: var(--text-2); font-size: 12px; }
.breadcrumb .icon { width: 15px; height: 15px; margin-left: 3px; }
.connection-state { color: var(--text-2); font-size: 12px; white-space: nowrap; }
.menu-button { display: none !important; }
.icon-button { display: inline-grid; width: 28px; height: 28px; place-items: center; border-radius: 6px; color: var(--text-2); }
.icon-button:hover { background: var(--hover); }
.icon-button .icon { width: 18px; height: 18px; }
.storage-notice { width: min(calc(100% - 96px), 860px); padding: 10px 14px; margin: 16px auto 0; border: 1px solid #F2E3B7; border-radius: 6px; background: #F7DCCA; color: #402C1B; font-size: 12px; }
.content { width: min(calc(100% - 96px), 860px); padding: 28px 0 64px; margin: 0 auto; }
.page-heading { margin-bottom: 20px; }
.page-date { color: var(--text-2); font-size: 12px; }
.page-title-line { display: flex; align-items: center; gap: 10px; margin-top: 2px; }
.page-title-line .icon { width: 32px; height: 32px; color: var(--text-3); }
.page-title-line h1 { font-size: 32px; font-weight: 700; letter-spacing: -.025em; line-height: 1.25; }
.page-description { margin-top: 6px; color: var(--text-2); font-size: 14px; }

.list-toolbar { display: grid; grid-template-columns: minmax(0, 1fr) 150px auto; gap: 8px; padding: 12px 0; border-top: 1px solid var(--divider); border-bottom: 1px solid var(--divider); }
.search-field { display: flex; align-items: center; gap: 7px; min-width: 0; padding: 0 9px; border-radius: 6px; background: var(--input-bg); color: var(--text-3); }
.search-field .icon { width: 17px; height: 17px; }
.search-field input { width: 100%; min-width: 0; height: 32px; border: 0; outline: 0; background: transparent; color: var(--text); }
.tag-filter { min-width: 0; height: 32px; padding: 0 8px; border: 0; border-radius: 6px; background: var(--input-bg); color: var(--text-2); }
.button-primary { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 32px; padding: 0 11px; border-radius: 6px; background: var(--blue); color: #fff; font-size: 13px; font-weight: 500; }
.button-primary:hover { background: var(--blue-hover); }
.button-primary .icon { width: 16px; height: 16px; }
.view-summary { display: flex; justify-content: space-between; gap: 12px; margin: 12px 0; color: var(--text-2); font-size: 12px; }
.view-summary button { color: var(--blue-text); text-decoration: underline; text-underline-offset: 2px; }
.quick-add { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 11px; margin: 16px 0 20px; border-radius: 6px; background: var(--input-bg); color: var(--text-3); }
.quick-add:focus-within { outline: 2px solid var(--focus); background: #fff; }
.quick-add .icon { width: 18px; height: 18px; }
.quick-add input { min-width: 0; height: 100%; flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); }
.quick-add input::placeholder, textarea::placeholder { color: var(--text-3); }

.task-section + .task-section { margin-top: 20px; }
.task-section.is-drop-target { padding: 4px 8px 8px; margin-right: -8px; margin-left: -8px; border-radius: 8px; outline: 2px inset rgba(35, 131, 226, .45); background: rgba(35, 131, 226, .06); }
.section-heading { display: flex; align-items: center; gap: 7px; min-height: 28px; }
.group-pill { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 2px 8px; border-radius: 999px; background: #E6E5E3; color: var(--text); font-size: 13px; font-weight: 500; }
.group-pill .icon { width: 14px; height: 14px; color: var(--text-2); }
.section-count { color: var(--text-3); font-size: 13px; font-variant-numeric: tabular-nums; }
.task-items { padding: 0; margin: 0; list-style: none; }
.task-row { display: flex; align-items: center; gap: 8px; min-width: 0; min-height: 40px; padding: 3px 4px; border-radius: 6px; }
.task-row:hover, .task-row:focus-within { background: var(--hover); }
.task-row.is-selected { background: var(--selected); }
.task-row.is-dragging { opacity: .4; }
.drag-handle { display: grid; width: 20px; height: 28px; flex: none; place-items: center; border-radius: 4px; color: var(--text-3); cursor: grab; touch-action: none; }
.drag-handle .icon { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.task-checkbox { display: grid; width: 16px; height: 16px; flex: none; place-content: center; margin: 0; appearance: none; border: 1.5px solid var(--text-3); border-radius: 4px; background: transparent; cursor: pointer; }
.task-checkbox::after { width: 8px; height: 4px; border-bottom: 2px solid #fff; border-left: 2px solid #fff; content: ""; transform: rotate(-45deg) translate(1px, -1px) scale(0); }
.task-checkbox:checked { border-color: var(--blue); background: var(--blue); }
.task-checkbox:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
.checkbox-priority-\!\!\! { border-color: #D44C47; }
.checkbox-priority-\!\! { border-color: #CB912F; }
.checkbox-priority-\! { border-color: #337EA9; }
.task-copy { display: flex; min-width: 0; flex: 1; align-items: center; gap: 8px; }
.task-title { min-width: 0; flex: 1; padding: 5px 0; overflow-wrap: anywhere; color: var(--text); text-align: left; }
.task-title[aria-current="true"] { font-weight: 600; }
.is-completed .task-title { color: var(--text-2); text-decoration: line-through; }
.task-meta { display: flex; align-items: center; justify-content: flex-end; gap: 5px; min-width: 0; color: var(--text-2); font-size: 12px; white-space: nowrap; }
.date-meta.tone-today { color: var(--blue-text); }
.date-meta.tone-overdue { color: var(--red-text); }
.date-meta.tone-completed { color: var(--text-3); }
.tag-badge, .priority-badge { display: inline-flex; align-items: center; min-height: 20px; padding: 1px 5px; border-radius: 4px; font-size: 11px; }
.tag-work, .tag-others { background: #F0EFED; color: #2C2C2B; }
.tag-money { background: #F7DCCA; color: #49290E; }
.tag-private { background: #F2E3B7; color: #402C1B; }
.tag-life { background: #DBECDD; color: #1C3829; }
.tag-event { background: #D3E5F2; color: #183347; }
.tag-hobby { background: #E8DDEF; color: #412454; }
.tag-anniversary { background: #F7DFEB; color: #4C2337; }
.badge-priority-\!\!\! { background: #F7D9D5; color: #5D1715; }
.badge-priority-\!\! { background: #F2E3B7; color: #402C1B; }
.badge-priority-\! { background: #D3E5F2; color: #183347; }
.task-menu-button { display: grid; width: 28px; height: 28px; flex: none; place-items: center; border-radius: 6px; color: var(--text-2); }
.task-menu-button:hover, .task-menu-button[aria-expanded="true"] { background: var(--active); }
.task-menu-button .icon { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.empty-group { min-height: 32px; padding: 6px 4px; color: var(--text-3); font-size: 13px; }
.empty-state { padding: 48px 16px; color: var(--text-2); text-align: center; }
.empty-state .icon { width: 28px; height: 28px; margin-bottom: 8px; color: var(--text-3); }
.empty-state h2 { color: var(--text); font-size: 16px; }
.empty-state p { margin-top: 5px; font-size: 13px; }

.task-menu { position: fixed; z-index: 40; display: flex; flex-direction: column; width: 248px; max-height: calc(100dvh - 16px); padding: 6px; overflow-y: auto; border-radius: 10px; background: #fff; box-shadow: var(--shadow); }
.menu-heading { padding: 6px 8px 3px; color: var(--text-3); font-size: 11px; }
.menu-separator { height: 1px; margin: 6px 0; background: var(--divider); }
.task-menu button { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 5px 8px; border-radius: 6px; text-align: left; }
.task-menu button:hover, .task-menu button:focus { outline: 0; background: var(--hover); }
.task-menu button .icon { width: 16px; height: 16px; color: var(--text-2); }
.task-menu .menu-check { margin-left: auto; color: var(--blue); }
.task-menu .danger, .task-menu .danger .icon { color: var(--red-text); }

.detail-panel { position: sticky; top: 0; height: 100dvh; overflow-y: auto; border-left: 1px solid var(--divider); background: #fff; }
.app-shell:has(.detail-panel:not([hidden])) { grid-template-columns: 248px minmax(0, 1fr) 420px; }
.detail-header { display: flex; align-items: center; justify-content: space-between; min-height: 44px; padding: 0 12px; border-bottom: 1px solid var(--divider); }
.detail-delete { color: var(--red-text); }
.detail-body { padding: 24px 32px 40px; }
.detail-title-line { display: flex; align-items: flex-start; gap: 10px; }
.detail-title-line .task-checkbox { margin-top: 9px; }
.detail-title { width: 100%; min-width: 0; padding: 3px 0; overflow: hidden; border: 0; outline: 0; background: transparent; color: var(--text); font-size: 24px; font-weight: 700; line-height: 1.35; resize: none; }
.detail-error { min-height: 18px; padding-left: 26px; margin: 2px 0 14px; color: var(--red-text); font-size: 12px; }
.detail-fields { margin-top: 18px; }
.detail-field { display: grid; grid-template-columns: 112px minmax(0, 1fr); align-items: center; gap: 8px; min-height: 34px; }
.detail-label { display: flex; align-items: center; gap: 6px; color: var(--text-2); font-size: 13px; }
.detail-label .icon { width: 16px; height: 16px; }
.detail-control { width: 100%; min-width: 0; min-height: 30px; padding: 3px 6px; border: 0; border-radius: 6px; outline: 0; background: transparent; color: var(--text); }
.detail-control:hover, .detail-control:focus { background: var(--hover); }
.detail-select { appearance: auto; }
.detail-shortcuts { display: flex; gap: 4px; }
.detail-shortcuts button { min-height: 28px; padding: 2px 5px; border-radius: 5px; color: var(--blue-text); font-size: 12px; }
.detail-shortcuts button:hover, .detail-shortcuts button[aria-pressed="true"] { background: var(--selected); font-weight: 600; }
.detail-completed { margin: 8px 0 0 120px; color: var(--text-2); font-size: 12px; }
.detail-notes { padding-top: 16px; margin-top: 18px; border-top: 1px solid var(--divider); }
.detail-notes textarea { width: 100%; min-height: 140px; border: 0; outline: 0; background: transparent; color: var(--text); resize: vertical; }
.detail-notes textarea:hover, .detail-notes textarea:focus { background: var(--hover); }

.overview-totals { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.overview-card, .completion-chart { padding: 18px; border: 1px solid var(--divider); border-radius: 8px; }
.overview-card strong { display: block; color: var(--text); font-size: 32px; font-variant-numeric: tabular-nums; }
.overview-card span { color: var(--text-2); font-size: 12px; }
.completion-chart { margin-top: 16px; }
.completion-chart h2 { margin-bottom: 16px; font-size: 14px; }
.completion-bars { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); align-items: end; gap: 8px; min-height: 180px; padding: 0; margin: 0; list-style: none; }
.completion-bar-item { display: grid; grid-template-rows: auto 120px auto; gap: 5px; min-width: 0; color: var(--text-2); font-size: 10px; text-align: center; }
.completion-bar-track { display: flex; align-items: end; height: 120px; border-bottom: 1px solid var(--divider); }
.completion-bar { width: 100%; min-height: 2px; height: var(--bar-size); border-radius: 4px 4px 0 0; background: var(--blue); }
.completion-bar-label { overflow-wrap: anywhere; }

.drag-ghost { position: fixed; z-index: 60; display: flex; align-items: center; gap: 8px; max-width: min(400px, calc(100vw - 32px)); min-height: 40px; padding: 6px 10px; overflow: hidden; border-radius: 6px; background: #fff; box-shadow: var(--shadow); color: var(--text); opacity: .95; pointer-events: none; }
.drag-ghost .icon { width: 16px; height: 16px; color: var(--text-3); }
.drag-ghost span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.undo-toast { position: fixed; bottom: 24px; left: 50%; z-index: 70; display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 32px); padding: 9px 8px 9px 14px; border-radius: 8px; background: #2C2C2B; box-shadow: var(--shadow); color: #fff; font-size: 13px; transform: translateX(-50%); }
.undo-toast #toast-message { min-width: 0; overflow-wrap: anywhere; }
.undo-toast #undo-action { min-height: 28px; flex: none; color: #7FB8F5; }
.undo-toast #dismiss-toast { display: grid; width: 28px; height: 28px; place-items: center; color: #fff; }
.undo-toast .icon { width: 16px; height: 16px; }
.bottom-nav { display: none; }

@media (min-width: 1280px) {
  .detail-panel { width: 420px; }
}

@media (min-width: 761px) and (max-width: 1279px) {
  .detail-panel { position: fixed; right: 0; z-index: 25; width: min(420px, calc(100vw - 64px)); border-left: 1px solid var(--divider); box-shadow: var(--shadow); }
  .app-shell:has(.detail-panel:not([hidden])) { grid-template-columns: 248px minmax(0, 1fr); }
}

@media (max-width: 760px) {
  .app-shell { display: block; min-height: 100dvh; }
  .sidebar { position: fixed; top: 0; left: 0; z-index: 30; width: min(290px, calc(100vw - 36px)); padding-top: 18px; box-shadow: var(--shadow); transform: translateX(-105%); transition: transform 120ms ease; }
  .app-shell.drawer-open .sidebar { transform: translateX(0); }
  .drawer-scrim { position: fixed; inset: 0; z-index: 29; background: rgba(15, 15, 15, .25); }
  .nav-button { min-height: 44px; }
  .main { padding-bottom: 68px; }
  .topbar { position: sticky; top: 0; z-index: 5; padding: 0 12px; background: #fff; }
  .menu-button { display: grid !important; }
  .connection-state { font-size: 11px; }
  .desktop-state { display: none; }
  .content { width: calc(100% - 32px); padding: 20px 0 28px; }
  .storage-notice { width: calc(100% - 32px); }
  .page-title-line .icon { width: 28px; height: 28px; }
  .page-title-line h1 { font-size: 26px; }
  .page-description { font-size: 13px; }
  .list-toolbar { grid-template-columns: minmax(0, 1fr) auto; }
  .search-field { grid-column: 1 / -1; }
  .tag-filter { width: 132px; }
  .quick-add { height: 44px; }
  .task-row { position: relative; align-items: flex-start; min-height: 56px; padding: 6px 2px; }
  .drag-handle { width: 24px; height: 40px; opacity: .45; }
  .drag-handle .icon { width: 16px; height: 16px; }
  .task-checkbox { margin-top: 10px; }
  .task-copy { display: block; padding-top: 1px; }
  .task-title { display: block; width: 100%; padding-top: 3px; }
  .task-meta { flex-wrap: wrap; justify-content: flex-start; padding-bottom: 3px; white-space: normal; }
  .task-menu-button { width: 44px; height: 44px; margin-left: auto; }
  .task-menu { width: min(248px, calc(100vw - 16px)); }
  .detail-panel { position: fixed; inset: 0; z-index: 35; width: 100%; height: 100dvh; border: 0; }
  .detail-body { padding: 20px 20px 44px; }
  .detail-field { grid-template-columns: 102px minmax(0, 1fr); }
  .detail-completed { margin-left: 110px; }
  .bottom-nav { position: fixed; right: 0; bottom: 0; left: 0; z-index: 20; display: grid; grid-template-columns: repeat(4, 1fr); height: 64px; border-top: 1px solid var(--divider); background: #fff; }
  .bottom-button { display: grid; min-width: 0; place-content: center; justify-items: center; gap: 2px; color: var(--text-2); font-size: 10px; }
  .bottom-button .icon { width: 19px; height: 19px; }
  .bottom-button[aria-current="page"], .bottom-button:hover { color: var(--blue-text); }
  .bottom-button.add-button > span:first-child { display: grid; width: 36px; height: 36px; margin-top: -15px; place-items: center; border-radius: 50%; background: var(--blue); box-shadow: 0 1px 4px rgba(15, 15, 15, .2); color: #fff; }
  .bottom-button.add-button > span:last-child { margin-top: -1px; color: var(--text-2); }
  .bottom-button.add-button .icon { width: 20px; height: 20px; }
  .undo-toast { bottom: 76px; }
  .overview-totals { grid-template-columns: 1fr; }
}

@media (max-width: 360px) {
  .content { width: calc(100% - 24px); }
  .tag-filter { width: 108px; }
  .button-primary { padding: 0 8px; }
  .button-primary .button-label { display: none; }
  .task-meta .tag-badge { max-width: 78px; overflow: hidden; text-overflow: ellipsis; }
  .detail-field { grid-template-columns: 86px minmax(0, 1fr); }
  .detail-label { font-size: 12px; }
  .detail-completed { margin-left: 94px; }
}

@media (hover: hover) and (pointer: fine) {
  .drag-handle { opacity: 0; }
  .task-row:hover .drag-handle { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}
