/* iOS Design System — Palette derived from custom poster (Deep Navy & Terracotta Orange) */
:root {
  --navy: #1b2a47;
  --navy-dark: #121d33;
  --navy-soft: #24375b;
  --orange: #e65c27;
  --orange-vibrant: #f26a35;
  --orange-soft: #fdeee6;
  --peach: #f7a072;
  --cream: #faf5ed;
  --cream-2: #f2e8dc;
  
  --bg: #f7f3ec;
  --bg-rgb: 247, 243, 236;
  --surface: #ffffff;
  --surface-rgb: 255, 255, 255;
  --surface-2: #efe7dc;
  --text: #17243c;
  --muted: #6e7d96;
  --line: rgba(27, 42, 71, 0.1);
  --line-hairline: rgba(27, 42, 71, 0.08);

  --accent: #e65c27;
  --accent-ink: #ffffff;
  --accent-soft: #fdeee6;
  --accent-blue: #1b2a47;
  
  --danger: #e53935;
  --success: #2e7d32;
  --success-soft: #e8f5e9;
  
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --radius-pill: 9999px;
  --nav-h: 60px;
  --shadow-sm: 0 1px 3px rgba(27, 42, 71, 0.05);
  --shadow-card: 0 4px 16px rgba(27, 42, 71, 0.05), 0 1px 2px rgba(27, 42, 71, 0.03);
  --shadow-btn: 0 3px 12px rgba(230, 92, 39, 0.28);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1826;
    --bg-rgb: 15, 24, 38;
    --surface: #172438;
    --surface-rgb: 23, 36, 56;
    --surface-2: #20314c;
    --text: #f7f9fd;
    --muted: #8e9db5;
    --line: rgba(247, 243, 236, 0.1);
    --line-hairline: rgba(247, 243, 236, 0.08);
    
    --accent: #f26a35;
    --accent-ink: #ffffff;
    --accent-soft: #2b1d16;
    --accent-blue: #3b578c;
    
    --orange-soft: #2e1a12;
    --cream-2: #20314c;
    --shadow-card: 0 4px 18px rgba(0, 0, 0, 0.35);
    --shadow-btn: 0 3px 14px rgba(242, 106, 53, 0.35);
  }
}

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

html {
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Segoe UI", Roboto, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, p { margin: 0; }
code {
  background: var(--surface-2);
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
}

#root {
  max-width: 580px;
  margin: 0 auto;
  padding: 0 16px calc(var(--nav-h) + 32px + env(safe-area-inset-bottom));
}

/* iOS Large Title Navigation Bar */
.top {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(16px + env(safe-area-inset-top)) 0 12px;
  background: rgba(var(--bg-rgb), 0.82);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 0.5px solid transparent;
  transition: border-color 0.2s ease;
}

.top h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  color: var(--text);
}

.top .btn {
  width: auto;
  min-height: 34px;
  padding: 0 14px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: var(--radius-pill);
}

/* Sections */
main {
  display: grid;
  gap: 24px;
  padding-top: 8px;
}

.section-title {
  font-size: 0.78rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 10px;
  padding-left: 2px;
}

.empty {
  color: var(--muted);
  font-size: 0.92rem;
  padding: 8px 4px;
}
.muted { color: var(--muted); }

/* iOS Status Banner: "All good for this week" */
.done-notice {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  background: var(--surface);
  border: 0.5px solid rgba(46, 125, 50, 0.28);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  margin-bottom: 8px;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  animation: fadeInNotice 0.22s ease-out;
}

.done-notice-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-pill);
  background: var(--success);
  color: #ffffff;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}

.done-notice-text {
  color: var(--text);
}

@keyframes fadeInNotice {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* iOS Inset Grouped Cards */
.cards {
  display: grid;
  gap: 14px;
  margin-bottom: 12px;
}

.card {
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  display: grid;
  gap: 14px;
  box-shadow: var(--shadow-card);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.card.is-next {
  border-color: var(--orange);
  box-shadow: 0 0 0 1.5px var(--orange), var(--shadow-card);
}

.card.is-done {
  opacity: 0.6;
}

.card.is-done h3 {
  text-decoration: line-through;
  text-decoration-color: var(--muted);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card h3 {
  font-size: 1.1rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}

/* iOS Badges */
.badge {
  font-size: 0.75rem;
  font-weight: 650;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  background: var(--orange-soft);
  color: var(--orange);
  letter-spacing: -0.01em;
}

.badge.ok {
  background: var(--surface-2);
  color: var(--muted);
}

/* Weekly Progress Bar (iOS Widget Style) */
.week-bar {
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 20px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow-card);
}

.week-bar-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.week-trackers {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.week-tracker {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 12px 6px;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 0.5px solid var(--line-hairline);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.week-tracker.done {
  background: var(--orange-soft);
  border-color: rgba(230, 92, 39, 0.3);
}

.week-tracker-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.week-tracker-label {
  font-size: 0.75rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--muted);
}

.week-tracker.done .week-tracker-label {
  color: var(--orange);
}

.week-tracker-status {
  font-size: 0.78rem;
  color: var(--muted);
  text-align: center;
  font-weight: 550;
}

.week-tracker.done .week-tracker-status {
  color: var(--orange);
  font-weight: 650;
}

.week-tracker-btn {
  appearance: none;
  border: none;
  background: var(--surface);
  color: var(--orange);
  border-radius: var(--radius-pill);
  padding: 4px 10px;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 650;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  margin-top: 2px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.week-tracker-btn:active {
  transform: scale(0.95);
}

.week-tracker.done .week-tracker-btn {
  background: var(--orange);
  color: #ffffff;
}

/* Segmented Cycle Progress Bar with Rounded Borders */
.cycle-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.cycle-progress {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 6px 8px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
}

.cycle-segs {
  display: flex;
  gap: 6px;
  width: 100%;
}

.cycle-segs i {
  height: 8px;
  flex: 1;
  border-radius: 99px;
  background: var(--surface-2);
  transition: background 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.cycle-segs i.on {
  background: var(--orange);
}

.btn-reset-cycle {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.12s ease, background 0.12s ease, color 0.12s ease;
}

.btn-reset-cycle:active {
  transform: scale(0.95);
  background: var(--surface-2);
  color: var(--text);
}

.btn-action-done {
  appearance: none;
  border: none;
  background: var(--orange);
  color: #ffffff;
  border-radius: var(--radius-pill);
  padding: 6px 14px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 650;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: var(--shadow-sm);
  white-space: nowrap;
  flex-shrink: 0;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn-action-done:active {
  transform: scale(0.95);
  filter: brightness(0.92);
}

/* Links & Inset Grouped Rows */
.links {
  display: grid;
  gap: 7px;
}

.link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  color: inherit;
  text-decoration: none;
  border: 0.5px solid transparent;
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), background 0.15s ease;
}

.link:active {
  transform: scale(0.98);
  filter: brightness(0.96);
}

/* Empty Link (no URL) */
.link.is-empty, .big-link.is-empty {
  cursor: default;
  opacity: 0.9;
}
.link.is-empty:active, .big-link.is-empty:active {
  transform: none;
  filter: none;
}
.link.is-empty .l-host {
  font-size: 0.75rem;
  font-style: italic;
  opacity: 0.55;
}

.pill.is-empty {
  cursor: default;
  opacity: 0.9;
}
.pill.is-empty:active {
  transform: none;
}

.link-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.l-icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.l-label {
  font-weight: 580;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.015em;
}

.l-host {
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Pills */
.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  background: var(--orange-soft);
  color: var(--orange);
  text-decoration: none;
  font-weight: 620;
  font-size: 0.92rem;
  transition: transform 0.15s ease;
}

.pill:active {
  transform: scale(0.96);
}

.pill .l-host { display: none; }

/* Large Hero Link */
.big {
  display: grid;
  gap: 10px;
}

.big-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 72px;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--navy), var(--orange));
  color: #ffffff;
  text-decoration: none;
  box-shadow: 0 6px 20px rgba(27, 42, 71, 0.18);
  transition: transform 0.15s ease;
}

.big-link:active {
  transform: scale(0.98);
}

.big-link .link-left { gap: 12px; }
.big-link .l-icon { font-size: 1.5rem; }
.big-link .l-label { font-size: 1.2rem; font-weight: 680; letter-spacing: -0.02em; }
.big-link .l-host { color: inherit; opacity: 0.8; font-size: 0.85rem; }

/* iOS Action Buttons */
.btn {
  appearance: none;
  border: none;
  font: inherit;
  font-weight: 650;
  letter-spacing: -0.01em;
  min-height: 46px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:active {
  transform: scale(0.975);
}

.btn.primary {
  background: var(--orange);
  color: #ffffff;
  box-shadow: var(--shadow-btn);
}

.btn.primary:active {
  filter: brightness(0.94);
}

.btn.ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 0.5px solid var(--line);
}

.btn.danger {
  background: transparent;
  color: var(--danger);
  border: 0.5px solid var(--line);
}

.btn.small {
  width: auto;
  min-height: 36px;
  padding: 0 14px;
  font-size: 0.9rem;
}

.big-btn {
  min-height: 52px;
  max-width: 300px;
  font-size: 1.05rem;
  border-radius: var(--radius-pill);
}

/* Edit Mode */
.edit-links {
  display: grid;
  gap: 10px;
}

.edit-links > .btn { justify-self: start; }

.link-edit {
  display: grid;
  gap: 8px;
  background: var(--surface);
  border: 0.5px solid var(--line);
  padding: 10px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.link-edit-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.link-edit-row input {
  flex: 1;
}

.app-preset-select {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
  background: var(--surface-2);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 10px;
  min-height: 42px;
  max-width: 160px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

.link-edit-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.link-edit-actions .icon-btn {
  min-height: 42px;
  min-width: 36px;
  font-size: 0.88rem;
  padding: 0 6px;
}

.link-edit-actions .icon-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

input {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  min-height: 42px;
  min-width: 0;
  width: 100%;
  transition: border-color 0.15s ease;
}

input:focus-visible,
.btn:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

.title-input {
  font-weight: 650;
  font-size: 1.05rem;
}

.icon-btn {
  appearance: none;
  border: 0.5px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  border-radius: var(--radius-sm);
  min-height: 42px;
  cursor: pointer;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease;
}

.icon-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.account {
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
  padding: 8px 0;
}

.linklike {
  appearance: none;
  background: none;
  border: 0;
  color: var(--orange);
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px;
}

/* Settings Panel */
.settings-panel {
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow-card);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.settings-label {
  font-size: 0.92rem;
  font-weight: 550;
  color: var(--text);
}

.settings-row input[type="number"] {
  width: 70px;
  min-height: 36px;
  text-align: center;
  border-radius: var(--radius-sm);
}

/* iOS Frosted Glass Tab Bar */
.tabs {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  justify-content: center;
  background: rgba(var(--surface-rgb), 0.84);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-top: 0.5px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabs button {
  flex: 1;
  max-width: 140px;
  height: var(--nav-h);
  appearance: none;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: transform 0.12s ease, color 0.12s ease;
}

.tabs button .tab-icon {
  font-size: 1.35rem;
  line-height: 1;
  transition: transform 0.12s ease;
}

.tabs button:active .tab-icon {
  transform: scale(0.9);
}

.tabs button.active {
  color: var(--orange);
}

.tabs button.active .tab-icon {
  transform: scale(1.08);
}

/* iOS Grouped History Sections */
.history-week {
  background: var(--surface);
  border: 0.5px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 14px;
  box-shadow: var(--shadow-card);
}

.history-week-header {
  padding: 12px 16px;
  background: var(--surface-2);
  border-bottom: 0.5px solid var(--line);
  font-weight: 700;
  font-size: 0.88rem;
  letter-spacing: -0.015em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.history-week-body {
  display: grid;
}

.history-row {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 0.5px solid var(--line-hairline);
  font-size: 0.92rem;
}

.history-row:last-child {
  border-bottom: none;
}

.history-hobby {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}

.history-detail {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 500;
  text-align: right;
}

.history-pill {
  font-size: 0.72rem;
  font-weight: 650;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
}

.history-pill.done {
  background: var(--orange-soft);
  color: var(--orange);
}

.history-pill.none {
  background: var(--surface-2);
  color: var(--muted);
}

.no-history {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
  font-size: 0.95rem;
}

/* Login View */
.center {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 24px 0;
}

.center.narrow {
  max-width: 420px;
  margin: 0 auto;
}

.logo {
  font-size: 3.5rem;
}

/* iOS Dynamic Toast Notification */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  z-index: 50;
  transform: translate(-50%, 14px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  background: var(--navy);
  color: #ffffff;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(27, 42, 71, 0.28);
  max-width: calc(100% - 32px);
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1), transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

#toast.show {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
