*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #FFFFFF;
  --card-bg: #FFFFFF;
  --teal: #30B0C7;
  --blue: #007AFF;
  --yellow: #FFCC00;
  --red: #FF3B30;
  --text: #000000;
  --text-secondary: #3C3C43;
  --text-tertiary: #8E8E93;
  --separator: #C6C6C8;
  --completed-text: #8E8E93;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1C1C1E;
    --card-bg: #2C2C2E;
    --text: #FFFFFF;
    --text-secondary: #EBEBF5;
    --text-tertiary: #636366;
    --separator: #38383A;
    --completed-text: #636366;
  }
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

#app {
  display: flex;
  justify-content: center;
}

#phone-frame {
  width: 393px;
  height: 852px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

#phone-frame {
  border-radius: 44px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.15);
}

/* Header */
header {
  padding: 16px 20px 8px;
}

header h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* NOW Card */
#now-card-wrapper {
  padding: 0 16px 8px;
}

#now-card {
  background: var(--teal);
  border-radius: 16px;
  padding: 16px;
  color: #fff;
}

#now-card .now-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  opacity: 0.85;
  margin-bottom: 6px;
}

#now-card .now-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 14px;
  line-height: 1.3;
}

#now-card .now-actions {
  display: flex;
  gap: 8px;
}

#now-card .btn-complete {
  flex: 1;
  background: rgba(255,255,255,0.95);
  color: var(--teal);
  border: none;
  border-radius: 10px;
  padding: 10px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

#now-card .btn-tomorrow {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

/* Tabs */
#tabs {
  display: flex;
  margin: 0 16px 12px;
  background: rgba(118,118,128,0.12);
  border-radius: 9px;
  padding: 2px;
  gap: 2px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: 7px;
  padding: 7px 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab.active {
  background: var(--card-bg);
  color: var(--text);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

/* Task List */
main {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 80px;
}

.section-header {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 4px 4px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card-bg);
  padding: 14px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--separator);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.task-item.removing {
  opacity: 0;
  transform: translateX(30px);
}

.check-btn {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--separator);
  background: transparent;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.check-btn.checked {
  background: var(--teal);
  border-color: var(--teal);
}

.check-btn.checked::after {
  content: '';
  width: 6px;
  height: 10px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translateY(-1px);
}

.task-text {
  flex: 1;
  font-size: 16px;
  line-height: 1.3;
  cursor: pointer;
}

.task-text.completed {
  color: var(--completed-text);
  text-decoration: line-through;
}

.task-text-input {
  flex: 1;
  font-size: 16px;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
}

.btn-tomorrow-row {
  background: none;
  border: none;
  color: var(--teal);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}

.btn-delete {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 18px;
  cursor: pointer;
  padding: 2px 4px;
  flex-shrink: 0;
}

.btn-delete:active {
  color: var(--red);
}

/* Date label for "すべて" tab */
.date-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-left: auto;
  flex-shrink: 0;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-tertiary);
}

.empty-state .empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 15px;
  margin-bottom: 4px;
}

.empty-state small {
  font-size: 13px;
}

/* Completed section toggle */
.completed-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 8px 4px 4px;
}

.completed-header span {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.completed-header .toggle-icon {
  color: var(--text-tertiary);
  font-size: 13px;
  transition: transform 0.15s ease;
}

.completed-header.open .toggle-icon {
  transform: rotate(90deg);
}

/* Input bar */
#input-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 393px;
  display: flex;
  gap: 8px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card-bg);
  border-top: 1px solid var(--separator);
}

#task-input {
  flex: 1;
  background: #F2F2F7;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 16px;
  color: var(--text);
  font-family: inherit;
  outline: none;
}

#task-input::placeholder {
  color: var(--text-tertiary);
}

#add-btn {
  background: var(--blue);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
