* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

:root {
  --paper: #f5f1e8;
  --paper-deep: #ebe5d5;
  --ink: #2c2826;
  --ink-soft: #5a5350;
  --ink-faint: #a39d94;
  --indigo: #6b7a8f;
  --line: #d8d2c2;
  --done: #b5a886;
  --routine: #8b9d83;
}

html, body {
  background: var(--paper);
  color: var(--ink);
  font-family: 'Shippori Mincho', 'Noto Sans JP', serif;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

body {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
}

.app { position: relative; z-index: 2; padding: 24px 22px 120px; }

header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}

.logo {
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.logo .en {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 14px;
  color: var(--ink-faint);
  margin-left: 8px;
  letter-spacing: 0.15em;
}

.header-right { display: flex; align-items: center; gap: 14px; }

.date {
  font-family: 'Cormorant Garamond', serif;
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.1em;
  text-align: right;
}

.date .day { display: block; font-size: 11px; color: var(--ink-faint); margin-top: 2px; }

.settings-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-soft);
}

.settings-btn svg { width: 16px; height: 16px; }
.settings-btn:active { background: var(--paper-deep); }

.greeting {
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

.greeting::before { content: '—'; margin-right: 8px; color: var(--ink-faint); }

.summary {
  font-size: 15px;
  line-height: 1.8;
  margin-bottom: 32px;
  color: var(--ink);
}

.summary .count {
  font-family: 'Cormorant Garamond', serif;
  font-size: 22px;
  font-weight: 500;
  margin: 0 2px;
  color: var(--indigo);
}

.section-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-label::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.focus-section { margin-bottom: 40px; }

.focus-button {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 2px;
  padding: 28px 24px;
  cursor: pointer;
  position: relative;
  transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  overflow: hidden;
  text-align: left;
  font-family: inherit;
}

.focus-button::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid var(--line);
  border-radius: 1px;
  pointer-events: none;
  transition: inset 0.4s;
}

.focus-button.routine-mode {
  border-color: var(--routine);
  background: linear-gradient(180deg, #f0ede0 0%, var(--paper) 60%);
}

.focus-button.routine-mode::before { border-color: rgba(139,157,131,0.3); }

.focus-button:active { transform: scale(0.98); background: var(--paper-deep); }
.focus-button:active::before { inset: 2px; }

.focus-label {
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.focus-label .dot {
  width: 6px;
  height: 6px;
  background: var(--indigo);
  border-radius: 50%;
  animation: pulse 2s ease-in-out infinite;
}

.focus-label .dot.routine { background: var(--routine); }

@keyframes pulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.3); }
}

.focus-task {
  font-size: 26px;
  font-weight: 500;
  line-height: 1.5;
  margin-bottom: 16px;
  color: var(--ink);
  letter-spacing: 0.02em;
  min-height: 39px;
}

.focus-task.empty {
  color: var(--ink-faint);
  font-size: 18px;
  font-style: italic;
}

.focus-task.empty::before { content: '— '; color: var(--ink-faint); }

.focus-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
  color: var(--ink-soft);
  flex-wrap: wrap;
}

.focus-meta .tag {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 1px;
  background: var(--paper-deep);
  letter-spacing: 0.1em;
  font-size: 11px;
}

.focus-meta .date-chip {
  font-family: 'Cormorant Garamond', serif;
  font-size: 13px;
  color: var(--indigo);
  font-style: italic;
}

.focus-meta .progress {
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px;
  color: var(--routine);
  font-style: italic;
  margin-left: auto;
}

.focus-actions {
  display: flex;
  gap: 10px;
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px dashed var(--line);
}

.focus-actions button {
  flex: 1;
  background: transparent;
  border: 1px solid var(--line);
  padding: 18px 8px;
  font-family: inherit;
  font-size: 16px;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.2s;
  letter-spacing: 0.08em;
  font-weight: 500;
  border-radius: 2px;
}

.focus-actions button.primary {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.focus-actions button.primary.routine {
  background: var(--routine);
  border-color: var(--routine);
}

.focus-actions button:active { transform: scale(0.96); }

.routine-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.routine-pills::-webkit-scrollbar { display: none; }

.routine-pill {
  flex-shrink: 0;
  padding: 8px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
}

.routine-pill .time-text {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  color: var(--ink-faint);
  font-size: 11px;
}

.routine-pill.active {
  border-color: var(--routine);
  background: rgba(139,157,131,0.08);
  color: var(--routine);
}

.today-button {
  width: 100%;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 16px 20px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  transition: all 0.3s;
}

.today-button:active {
  transform: scale(0.99);
  background: var(--paper-deep);
}

.today-button-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.today-button-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--indigo);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.today-button-icon svg { width: 16px; height: 16px; }

.today-button-text {
  font-size: 15px;
  color: var(--ink);
  letter-spacing: 0.03em;
}

.today-button-text .en {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 11px;
  color: var(--ink-faint);
  margin-left: 6px;
  letter-spacing: 0.15em;
}

.today-button-count {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-style: italic;
  color: var(--indigo);
}

.task-list { margin-bottom: 32px; }

.task {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 4px;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  transition: opacity 0.3s;
}

.task:last-child { border-bottom: none; }

.check {
  width: 18px;
  height: 18px;
  border: 1px solid var(--ink-soft);
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 3px;
  position: relative;
  transition: all 0.3s;
}

.task.done .check { background: var(--done); border-color: var(--done); }

.task.done .check::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 2px;
  width: 4px;
  height: 9px;
  border: solid var(--paper);
  border-width: 0 1.5px 1.5px 0;
  transform: rotate(45deg);
}

.task.done .task-text {
  color: var(--ink-faint);
  text-decoration: line-through;
  text-decoration-thickness: 0.5px;
}

.task.current {
  background: rgba(139,157,131,0.06);
  border-radius: 2px;
  padding-left: 10px;
  padding-right: 10px;
  margin-left: -10px;
  margin-right: -10px;
  border-bottom-color: var(--routine);
}

.task.current .task-text {
  color: var(--routine);
  font-weight: 500;
}

.task.current .check {
  border-color: var(--routine);
}

.task.current-today {
  background: rgba(107,122,143,0.06);
  border-radius: 2px;
  padding-left: 10px;
  padding-right: 10px;
  margin-left: -10px;
  margin-right: -10px;
  border-bottom-color: var(--indigo);
}

.task.current-today .task-text {
  color: var(--indigo);
  font-weight: 500;
}

.task.current-today .check {
  border-color: var(--indigo);
}

.task-body { flex: 1; min-width: 0; }

.task-text {
  font-size: 15px;
  line-height: 1.5;
  margin-bottom: 4px;
  color: var(--ink);
}

.task-sub {
  font-size: 11px;
  color: var(--ink-faint);
  letter-spacing: 0.08em;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.task-sub .cat {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 12px;
}

.task-sub .date-mark {
  font-family: 'Cormorant Garamond', serif;
  font-size: 12px;
  color: var(--indigo);
  font-style: italic;
}

.fab-wrap {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  width: 100%;
  max-width: 430px;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  padding: 0 32px;
  align-items: center;
}

.fab-secondary {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  cursor: pointer;
  pointer-events: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(44,40,38,0.1);
}

.fab-secondary svg { width: 18px; height: 18px; }
.fab-secondary:active { transform: scale(0.93); }

.fab {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--paper);
  border: none;
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  box-shadow: 0 8px 24px rgba(44,40,38,0.18), 0 2px 6px rgba(44,40,38,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
}

.fab:active { transform: scale(0.93); }
.fab svg { width: 26px; height: 26px; }

.fab.recording {
  background: #8b4444;
  animation: recordPulse 1.4s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(139,68,68,0.3), 0 0 0 0 rgba(139,68,68,0.4); }
  50% { box-shadow: 0 8px 24px rgba(139,68,68,0.3), 0 0 0 16px rgba(139,68,68,0); }
}

.fab-spacer { width: 48px; }

.overlay {
  position: fixed;
  inset: 0;
  max-width: 430px;
  margin: 0 auto;
  background: rgba(245,241,232,0.96);
  backdrop-filter: blur(8px);
  z-index: 20;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.overlay.active { display: flex; }

.overlay-label {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 16px;
  color: var(--ink-soft);
  letter-spacing: 0.15em;
  margin-bottom: 32px;
}

.wave {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 60px;
  margin-bottom: 32px;
}

.wave span {
  display: block;
  width: 3px;
  background: var(--ink);
  border-radius: 2px;
  animation: wave 1s ease-in-out infinite;
}

.wave span:nth-child(1) { height: 20%; animation-delay: 0s; }
.wave span:nth-child(2) { height: 40%; animation-delay: 0.1s; }
.wave span:nth-child(3) { height: 80%; animation-delay: 0.2s; }
.wave span:nth-child(4) { height: 100%; animation-delay: 0.3s; }
.wave span:nth-child(5) { height: 60%; animation-delay: 0.4s; }
.wave span:nth-child(6) { height: 80%; animation-delay: 0.5s; }
.wave span:nth-child(7) { height: 30%; animation-delay: 0.6s; }
.wave span:nth-child(8) { height: 50%; animation-delay: 0.7s; }

@keyframes wave {
  0%, 100% { transform: scaleY(0.5); opacity: 0.5; }
  50% { transform: scaleY(1.2); opacity: 1; }
}

.overlay-hint {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 1.8;
  text-align: center;
  margin-bottom: 40px;
  letter-spacing: 0.05em;
}

.overlay-stop {
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 14px 36px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.2em;
  border-radius: 2px;
  cursor: pointer;
}

.toast {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: var(--paper);
  padding: 12px 24px;
  border-radius: 2px;
  font-size: 13px;
  letter-spacing: 0.1em;
  opacity: 0;
  transition: all 0.4s;
  z-index: 30;
  pointer-events: none;
  max-width: 80%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal {
  position: fixed;
  inset: 0;
  max-width: 430px;
  margin: 0 auto;
  background: rgba(44,40,38,0.4);
  z-index: 40;
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal.active { display: flex; }

.modal-content {
  background: var(--paper);
  width: 100%;
  border-radius: 8px 8px 0 0;
  padding: 28px 22px 32px;
  animation: slideUp 0.3s ease-out;
  max-height: 88vh;
  overflow-y: auto;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.modal-title {
  font-size: 18px;
  margin-bottom: 24px;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 22px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.field { margin-bottom: 18px; }

.field-label {
  font-family: 'Cormorant Garamond', serif;
  font-size: 11px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-bottom: 8px;
  display: block;
}

.field input[type="text"],
.field input[type="time"],
.field select {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  font-family: inherit;
  font-size: 15px;
  color: var(--ink);
  outline: none;
}

.field input:focus { border-bottom-color: var(--ink); }

.chip-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.chip {
  padding: 6px 14px;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  font-family: inherit;
}

.chip.selected {
  background: var(--ink);
  color: var(--paper);
  border-color: var(--ink);
}

.cal-quick {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.cal-quick .chip {
  flex: 1;
  min-width: 60px;
  text-align: center;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  margin-top: 12px;
}

.cal-header {
  text-align: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 11px;
  color: var(--ink-faint);
  padding: 6px 0;
  letter-spacing: 0.1em;
}

.cal-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.2s;
}

.cal-day.muted { color: var(--ink-faint); }
.cal-day.today { font-weight: 600; border: 1px solid var(--line); }
.cal-day.selected { background: var(--ink); color: var(--paper); }
.cal-day:active { background: var(--paper-deep); }

.cal-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.cal-month {
  font-family: 'Cormorant Garamond', serif;
  font-size: 16px;
  font-style: italic;
  letter-spacing: 0.1em;
}

.cal-nav button {
  background: transparent;
  border: 1px solid var(--line);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  color: var(--ink-soft);
  font-family: inherit;
}

.submit-btn {
  width: 100%;
  background: var(--ink);
  color: var(--paper);
  border: none;
  padding: 14px;
  font-family: inherit;
  font-size: 14px;
  letter-spacing: 0.2em;
  border-radius: 2px;
  cursor: pointer;
  margin-top: 8px;
}

.settings-page {
  position: fixed;
  inset: 0;
  max-width: 430px;
  margin: 0 auto;
  background: var(--paper);
  z-index: 50;
  overflow-y: auto;
  display: none;
  padding: 24px 22px 60px;
}

.settings-page.active { display: block; }

.settings-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}

.back-btn {
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-soft);
}

.settings-title { font-size: 18px; letter-spacing: 0.05em; }

.routine-card {
  border: 1px solid var(--line);
  padding: 16px;
  margin-bottom: 12px;
  background: var(--paper);
  border-radius: 2px;
}

.routine-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
}

.routine-card-name { font-size: 16px; font-weight: 500; }

.routine-card-time {
  font-family: 'Cormorant Garamond', serif;
  font-style: italic;
  font-size: 16px;
  color: var(--routine);
}

.routine-card-items {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.7;
}

.routine-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.routine-card-actions button {
  background: transparent;
  border: 1px solid var(--line);
  padding: 6px 12px;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 2px;
}

.add-routine-btn {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--ink-soft);
  padding: 14px;
  font-family: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  cursor: pointer;
  border-radius: 2px;
  margin-top: 8px;
  letter-spacing: 0.1em;
}

.routine-items-input {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.routine-item-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.routine-item-row input {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 8px 0;
  font-family: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
}

.routine-item-row .remove-x {
  background: transparent;
  border: none;
  color: var(--ink-faint);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}

.add-item-mini {
  background: transparent;
  border: none;
  color: var(--ink-soft);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  text-align: left;
  font-family: inherit;
  letter-spacing: 0.08em;
}

.fade-in {
  opacity: 0;
  transform: translateY(8px);
  animation: fadeIn 0.6s forwards;
}

@keyframes fadeIn { to { opacity: 1; transform: translateY(0); } }

.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
