/* =========================================================================
   our-tasks — Apple Design準拠
   出典: DESIGN.md (getdesign / apple)
   原則: 単一アクセント (Action Blue #0066cc) / pill CTA / 単一影 / 微差サーフェス
   ========================================================================= */

:root {
  /* Colors */
  --c-primary: #0066cc;
  --c-primary-focus: #0071e3;
  --c-primary-on-dark: #2997ff;
  --c-ink: #1d1d1f;
  --c-ink-muted-80: #333333;
  --c-ink-muted-48: #7a7a7a;
  --c-canvas: #ffffff;
  --c-parchment: #f5f5f7;
  --c-pearl: #fafafc;
  --c-hairline: #e0e0e0;
  --c-divider: #f0f0f0;
  --c-tile-dark: #272729;
  --c-translucent-chip: rgba(210, 210, 215, 0.64);
  --c-danger: #ff3b30;

  /* Spacing (8px base, + 17px body line) */
  --s-xxs: 4px;
  --s-xs: 8px;
  --s-sm: 12px;
  --s-md: 17px;
  --s-lg: 24px;
  --s-xl: 32px;
  --s-xxl: 48px;

  /* Radius */
  --r-sm: 8px;
  --r-md: 11px;
  --r-lg: 18px;
  --r-pill: 9999px;

  /* Type */
  --f-display: "SF Pro Display", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  --f-text: "SF Pro Text", system-ui, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;

  /* Single product shadow (Apple's only drop-shadow) */
  --shadow-product: 0 3px 5px rgba(0, 0, 0, 0.06), 0 5px 30px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--c-parchment);
  color: var(--c-ink);
  font-family: var(--f-text);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.374px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
  overflow-x: hidden;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { -webkit-tap-highlight-color: transparent; }

input[type="text"], input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
}

::selection { background: rgba(0, 102, 204, 0.18); }

/* ============================================================
   Top Bar (sub-nav-frosted モチーフ)
   ============================================================ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(245, 245, 247, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  padding-top: env(safe-area-inset-top);
}

.topbar__inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 var(--s-md);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-sm);
}

.topbar__title {
  margin: 0;
  font-family: var(--f-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.19;
  letter-spacing: 0.231px;
  color: var(--c-ink);
}

/* ============================================================
   Icon Button (44x44, pill, scale on press)
   ============================================================ */

.iconbtn {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  color: var(--c-primary);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: transform 120ms ease, background-color 200ms ease;
}
.iconbtn:active { transform: scale(0.95); }
.iconbtn:focus-visible {
  outline: 2px solid var(--c-primary-focus);
  outline-offset: 2px;
}
.iconbtn--primary {
  background: var(--c-primary);
  color: #fff;
}

/* ============================================================
   Page Layout
   ============================================================ */

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--s-md) var(--s-md) calc(var(--s-xxl) + env(safe-area-inset-bottom));
}

/* ============================================================
   Filter Bar
   ============================================================ */

.filterbar {
  margin-bottom: var(--s-lg);
}

.filterbar__seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--c-divider);
  padding: 3px;
  border-radius: var(--r-md);
  gap: 0;
}

.filterbar__btn {
  background: transparent;
  border: 0;
  padding: 0 var(--s-xs);
  min-height: 38px;
  border-radius: 9px;
  font-family: var(--f-text);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.224px;
  color: var(--c-ink);
  cursor: pointer;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 120ms ease, color 160ms ease;
  -webkit-tap-highlight-color: transparent;
}
.filterbar__btn:active { transform: scale(0.97); }
.filterbar__btn[aria-selected="true"] {
  background: var(--c-canvas);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.08);
  font-weight: 600;
  color: var(--c-ink);
}
.filterbar__btn:focus-visible {
  outline: 2px solid var(--c-primary-focus);
  outline-offset: 2px;
}

.section { margin-bottom: var(--s-xl); }
.section:last-child { margin-bottom: 0; }

.section__head {
  display: flex;
  align-items: center;
  gap: var(--s-xs);
  padding: var(--s-sm) var(--s-xxs) var(--s-sm);
  background: transparent;
  border: 0;
  width: 100%;
  text-align: left;
  color: var(--c-ink);
}

.section__head--btn {
  cursor: pointer;
  min-height: 44px;
  transition: opacity 120ms ease;
}
.section__head--btn:active { opacity: 0.6; }

.section__title {
  margin: 0;
  font-family: var(--f-display);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.19;
  letter-spacing: 0.231px;
}

.section__count {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.224px;
  color: var(--c-ink-muted-48);
  font-variant-numeric: tabular-nums;
}

.section__head--btn .chev {
  margin-left: auto;
  color: var(--c-ink-muted-48);
  transition: transform 220ms cubic-bezier(0.4, 0, 0.2, 1);
}
.section__head--btn[aria-expanded="true"] .chev {
  transform: rotate(-180deg);
}

/* ============================================================
   Task List (store-utility-card モチーフ)
   ============================================================ */

.tasklist {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--c-canvas);
  border: 1px solid var(--c-hairline);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.tasklist--done .task__title { color: var(--c-ink-muted-48); text-decoration: line-through; text-decoration-color: rgba(122, 122, 122, 0.5); text-decoration-thickness: 1px; }
.tasklist--done .task__check { background: var(--c-primary); border-color: var(--c-primary); color: #fff; }

.task {
  display: grid;
  grid-template-columns: 28px 1fr;
  column-gap: var(--s-sm);
  align-items: flex-start;
  padding: var(--s-md);
  border-bottom: 1px solid var(--c-divider);
  cursor: pointer;
  transition: background-color 120ms ease;
  min-height: 60px;
}
.task:last-child { border-bottom: 0; }
.task:active { background-color: var(--c-pearl); }

.task__check {
  grid-row: 1 / span 2;
  margin-top: 2px;
  width: 26px;
  height: 26px;
  flex: none;
  border: 1.5px solid var(--c-ink-muted-48);
  background: transparent;
  color: transparent;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease, transform 120ms ease;
  -webkit-appearance: none;
  appearance: none;
  padding: 0;
}
.task__check:active { transform: scale(0.92); }
.task__check svg { width: 14px; height: 14px; pointer-events: none; }

.task__title {
  margin: 0;
  font-family: var(--f-text);
  font-size: 17px;
  font-weight: 400;
  line-height: 1.29;
  letter-spacing: -0.374px;
  color: var(--c-ink);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.task__meta {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-xs);
}

.task__chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.12px;
  color: var(--c-ink-muted-48);
  background: var(--c-parchment);
  padding: 5px 10px;
  border-radius: var(--r-pill);
}
.task__chip--btn {
  border: 0;
  cursor: pointer;
  font-family: var(--f-text);
  font-weight: 600;
  padding: 6px 12px;
  transition: transform 120ms ease, opacity 160ms ease;
  -webkit-tap-highlight-color: transparent;
  min-height: 28px;
}
.task__chip--btn:active { transform: scale(0.94); opacity: 0.85; }
.task__chip--btn:focus-visible {
  outline: 2px solid var(--c-primary-focus);
  outline-offset: 2px;
}
.task__chip--mine {
  color: var(--c-primary);
  background: rgba(0, 102, 204, 0.08);
}
.task__chip--kanai {
  color: #af52de;
  background: rgba(175, 82, 222, 0.10);
}
.task__chip--yabuoshi {
  color: var(--c-primary);
  background: rgba(0, 102, 204, 0.08);
}
.task__chip--both {
  color: var(--c-ink-muted-80);
  background: var(--c-divider);
}
.task__chip--overdue {
  color: var(--c-danger);
  background: rgba(255, 59, 48, 0.08);
}
.task__chip--today {
  color: var(--c-ink);
  background: rgba(0, 102, 204, 0.08);
  font-weight: 600;
}

/* ============================================================
   Empty
   ============================================================ */

.empty {
  margin: 0;
  padding: var(--s-xl) var(--s-md);
  text-align: center;
  color: var(--c-ink-muted-48);
  background: var(--c-canvas);
  border: 1px solid var(--c-hairline);
  border-radius: var(--r-lg);
  font-size: 14px;
  letter-spacing: -0.224px;
}

/* ============================================================
   Splash
   ============================================================ */

.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--c-parchment);
  transition: opacity 220ms ease;
}
.splash[hidden] { display: none; }
.splash.hide { opacity: 0; pointer-events: none; }

.splash__dots {
  display: flex;
  gap: 8px;
}
.splash__dots i {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--c-ink-muted-48);
  animation: dot 1.1s infinite ease-in-out;
}
.splash__dots i:nth-child(2) { animation-delay: 0.15s; }
.splash__dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes dot {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* ============================================================
   Modal (Bottom Sheet on mobile / Centered on tablet+)
   ============================================================ */

.modal {
  border: 0;
  padding: 0;
  margin: 0;
  background: transparent;
  width: 100%;
  max-width: 100%;
  max-height: 100dvh;
  color: var(--c-ink);
}
.modal::backdrop {
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(2px);
}
.modal[open] {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: sheet-in 240ms cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes sheet-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal__inner {
  width: 100%;
  max-width: 560px;
  background: var(--c-canvas);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  display: flex;
  flex-direction: column;
  max-height: 92dvh;
  overflow: hidden;
  padding-bottom: env(safe-area-inset-bottom);
  animation: sheet-up 280ms cubic-bezier(0.32, 0.72, 0, 1);
}
@keyframes sheet-up {
  from { transform: translateY(24px); }
  to { transform: translateY(0); }
}

@media (min-width: 640px) {
  .modal[open] { align-items: center; }
  .modal__inner {
    border-radius: var(--r-lg);
    margin: var(--s-md);
    max-height: 80dvh;
  }
}

.modal__head {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: var(--s-xs);
  padding: var(--s-sm) var(--s-md);
  border-bottom: 1px solid var(--c-divider);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.modal__title {
  margin: 0;
  font-family: var(--f-text);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.374px;
  text-align: center;
  white-space: nowrap;
}

.modal__btn {
  background: transparent;
  border: 0;
  color: var(--c-primary);
  font-family: var(--f-text);
  font-size: 17px;
  letter-spacing: -0.374px;
  padding: var(--s-xs) var(--s-sm);
  min-height: 44px;
  min-width: 44px;
  cursor: pointer;
  border-radius: var(--r-sm);
  transition: opacity 120ms ease;
}
.modal__btn:first-child { justify-self: start; }
.modal__btn:last-child { justify-self: end; }
.modal__btn:active { opacity: 0.5; }
.modal__btn--primary { font-weight: 600; }
.modal__btn[disabled] {
  color: var(--c-ink-muted-48);
  cursor: not-allowed;
  opacity: 0.6;
}

.modal__body {
  padding: var(--s-lg) var(--s-md) var(--s-xl);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--s-lg);
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   Form Field
   ============================================================ */

.field {
  display: flex;
  flex-direction: column;
  gap: var(--s-xs);
  border: 0;
  padding: 0;
  margin: 0;
  min-width: 0;
}

.field__label {
  font-family: var(--f-text);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.29;
  letter-spacing: -0.224px;
  color: var(--c-ink-muted-80);
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 0;
}

.field__optional {
  font-weight: 400;
  color: var(--c-ink-muted-48);
  font-size: 12px;
  letter-spacing: -0.12px;
}

.input {
  width: 100%;
  background: var(--c-canvas);
  border: 1px solid var(--c-hairline);
  border-radius: var(--r-md);
  padding: 0 var(--s-md);
  font-family: var(--f-text);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.374px;
  color: var(--c-ink);
  min-height: 48px;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input::placeholder { color: var(--c-ink-muted-48); }
.input:focus {
  outline: 0;
  border-color: var(--c-primary-focus);
  box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.18);
}

input[type="date"].input {
  padding: 0 var(--s-md);
  min-height: 48px;
}

/* ============================================================
   Segmented Control (Apple-style)
   ============================================================ */

.seg {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--c-divider);
  padding: 2px;
  border-radius: var(--r-md);
  gap: 0;
  position: relative;
}
.seg input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
  width: 0; height: 0;
}
.seg label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--s-sm);
  border-radius: 9px;
  cursor: pointer;
  font-family: var(--f-text);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.224px;
  color: var(--c-ink);
  min-height: 36px;
  transition: background-color 160ms ease, box-shadow 160ms ease, transform 120ms ease;
  user-select: none;
  -webkit-user-select: none;
}
.seg label:active { transform: scale(0.97); }
.seg input:checked + label {
  background: var(--c-canvas);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}
.seg input:focus-visible + label {
  outline: 2px solid var(--c-primary-focus);
  outline-offset: 2px;
}

/* ============================================================
   Danger Link
   ============================================================ */

.danger-link {
  background: transparent;
  border: 0;
  color: var(--c-danger);
  font-family: var(--f-text);
  font-size: 17px;
  letter-spacing: -0.374px;
  padding: var(--s-sm);
  min-height: 44px;
  cursor: pointer;
  align-self: center;
  margin-top: var(--s-xs);
  border-radius: var(--r-sm);
  transition: opacity 120ms ease;
}
.danger-link:active { opacity: 0.5; }

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  bottom: calc(env(safe-area-inset-bottom) + var(--s-md));
  background: var(--c-ink);
  color: #fff;
  border-radius: var(--r-pill);
  padding: 10px var(--s-md);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.224px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
  z-index: 2000;
  max-width: calc(100% - var(--s-xl));
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Reduced Motion
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ============================================================
   Tablet+
   ============================================================ */

@media (min-width: 736px) {
  .page { padding: var(--s-lg) var(--s-lg) var(--s-xxl); }
  .topbar__inner { height: 56px; }
  .topbar__title { font-size: 24px; }
}
