:root {
  --bg: #10151d;
  --surface: #171f2a;
  --surface-strong: #1f2936;
  --surface-soft: #232f3e;
  --input-bg: #111820;
  --card-bg: rgba(23, 31, 42, 0.9);
  --modal-bg: rgba(23, 31, 42, 0.94);
  --sidebar-bg: rgba(14, 18, 25, 0.86);
  --item-bg: rgba(255, 255, 255, 0.035);
  --track-bg: #111820;
  --text: #f5f7fb;
  --muted: #aab5c4;
  --faint: #728094;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #70d6c3;
  --accent-strong: #4fb6a4;
  --gold: #f2c86b;
  --danger: #ff8f8f;
  --success: #8be28b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
  min-width: 0;
}

html {
  min-height: 100%;
  background: #10151d;
  color-scheme: dark;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(circle at 20% 0%, rgba(112, 214, 195, 0.14), transparent 34rem),
    linear-gradient(135deg, #0e1219 0%, var(--bg) 48%, #151419 100%);
  background-color: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overscroll-behavior-y: none;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(circle at 20% 0%, rgba(112, 214, 195, 0.14), transparent 34rem),
    linear-gradient(135deg, #0e1219 0%, var(--bg) 48%, #151419 100%);
  pointer-events: none;
}

body.light-theme {
  --bg: #eef3f7;
  --surface: #ffffff;
  --surface-strong: #e6edf3;
  --surface-soft: #edf4f8;
  --input-bg: #ffffff;
  --card-bg: rgba(255, 255, 255, 0.96);
  --modal-bg: #ffffff;
  --sidebar-bg: rgba(255, 255, 255, 0.9);
  --item-bg: rgba(15, 34, 50, 0.045);
  --track-bg: #dce6ee;
  --text: #16202b;
  --muted: #5d6b7a;
  --faint: #8290a0;
  --line: rgba(22, 32, 43, 0.12);
  --shadow: 0 20px 55px rgba(21, 35, 50, 0.12);
}

body.light-theme {
  background:
    radial-gradient(circle at 20% 0%, rgba(79, 182, 164, 0.16), transparent 34rem),
    linear-gradient(135deg, #f7fbfd 0%, var(--bg) 48%, #f1f4f7 100%);
  background-color: var(--bg);
}

html:has(body.light-theme) {
  background: #eef3f7;
  color-scheme: light;
}

body.light-theme::before {
  background:
    radial-gradient(circle at 20% 0%, rgba(79, 182, 164, 0.16), transparent 34rem),
    linear-gradient(135deg, #f7fbfd 0%, var(--bg) 48%, #f1f4f7 100%);
}

body:not(.auth-panel-open) .auth-screen,
body.authenticated .auth-screen {
  display: none;
}

body.authenticated .sign-in-nav-button {
  display: none;
}

body.authenticated .sidebar-actions .settings-desktop {
  display: none;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--text);
  padding: 0.8rem 0.9rem;
  outline: none;
}

input:focus,
select:focus {
  border-color: rgba(112, 214, 195, 0.72);
  box-shadow: 0 0 0 3px rgba(112, 214, 195, 0.14);
}

input[type="checkbox"] {
  width: auto;
  accent-color: var(--accent);
}

.app-shell {
  display: grid;
  grid-template-columns: 280px 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

.modal-screen {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding:
    calc(1.25rem + env(safe-area-inset-top))
    calc(1.25rem + env(safe-area-inset-right))
    calc(1.25rem + env(safe-area-inset-bottom))
    calc(1.25rem + env(safe-area-inset-left));
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(8, 12, 17, 0.78);
  backdrop-filter: blur(12px);
}

.auth-card,
.modal-card {
  position: relative;
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--modal-bg);
  box-shadow: var(--shadow);
  padding: 1.5rem;
}

.modal-card {
  width: min(560px, 100%);
}

.compact-modal {
  width: min(460px, 100%);
}

.auth-close {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  background: var(--surface-soft);
  color: var(--muted);
}

.auth-brand {
  margin-bottom: 1.5rem;
}

.modal-heading {
  margin-bottom: 1rem;
  padding-right: 2.4rem;
}

.modal-heading h2 {
  margin: 0.2rem 0 0;
}

.modal-copy {
  margin: 0 0 1.1rem;
  color: var(--muted);
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.7rem;
  margin-top: 1rem;
}

.modal-actions button {
  min-width: 7.5rem;
}

.auth-form {
  display: grid;
  gap: 0.55rem;
}

.auth-form button {
  margin-top: 0.35rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.15rem 0 0.45rem;
  color: var(--faint);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.auth-message {
  min-height: 1.2rem;
  margin: 0.9rem 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.auth-message.error {
  color: var(--danger);
}

.auth-message.success {
  color: var(--success);
}

.gsi-material-button {
  -moz-user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
  -webkit-appearance: none;
  background-color: WHITE;
  background-image: none;
  border: 1px solid #747775;
  -webkit-border-radius: 20px;
  border-radius: 20px;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
  color: #1f1f1f;
  cursor: pointer;
  font-family: 'Roboto', arial, sans-serif;
  font-size: 14px;
  height: 40px;
  letter-spacing: 0.25px;
  outline: none;
  overflow: hidden;
  padding: 0 12px;
  position: relative;
  text-align: center;
  -webkit-transition: background-color .218s, border-color .218s, box-shadow .218s;
  transition: background-color .218s, border-color .218s, box-shadow .218s;
  vertical-align: middle;
  white-space: nowrap;
  width: 100%;
  max-width: 400px;
  min-width: min-content;
}

.gsi-material-button .gsi-material-button-icon {
  height: 20px;
  margin-right: 10px;
  min-width: 20px;
  width: 20px;
}

.gsi-material-button .gsi-material-button-content-wrapper {
  -webkit-align-items: center;
  align-items: center;
  display: flex;
  -webkit-flex-direction: row;
  flex-direction: row;
  -webkit-flex-wrap: nowrap;
  flex-wrap: nowrap;
  height: 100%;
  justify-content: space-between;
  position: relative;
  width: 100%;
}

.gsi-material-button .gsi-material-button-contents {
  -webkit-flex-grow: 1;
  flex-grow: 1;
  font-family: 'Roboto', arial, sans-serif;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: top;
}

.gsi-material-button .gsi-material-button-state {
  -webkit-transition: opacity .218s;
  transition: opacity .218s;
  bottom: 0;
  left: 0;
  opacity: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.gsi-material-button:disabled {
  cursor: default;
  background-color: #ffffff61;
  border-color: #1f1f1f1f;
}

.gsi-material-button:disabled .gsi-material-button-contents {
  opacity: 38%;
}

.gsi-material-button:disabled .gsi-material-button-icon {
  opacity: 38%;
}

.gsi-material-button:not(:disabled):active .gsi-material-button-state,
.gsi-material-button:not(:disabled):focus .gsi-material-button-state {
  background-color: #303030;
  opacity: 12%;
}

.gsi-material-button:not(:disabled):hover {
  -webkit-box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15);
  box-shadow: 0 1px 2px 0 rgba(60, 64, 67, .30), 0 1px 3px 1px rgba(60, 64, 67, .15);
}

.gsi-material-button:not(:disabled):hover .gsi-material-button-state {
  background-color: #303030;
  opacity: 8%;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 1.5rem;
  background: var(--sidebar-bg);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-bottom: 2rem;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--gold));
  color: #10151d;
  font-weight: 800;
}

.brand h1,
.brand p,
.section-heading h2,
.section-heading p,
.panel h3,
.panel p {
  margin: 0;
}

.brand h1 {
  font-size: 1.35rem;
}

.brand p,
.eyebrow,
.stat-card span,
.panel-subhead span {
  color: var(--muted);
}

.nav-tabs {
  display: grid;
  gap: 0.55rem;
}

.sign-in-nav-button {
  margin-top: auto;
  width: 100%;
}

.settings-icon-button {
  display: grid;
  place-items: center;
  width: 2.7rem;
  height: 2.7rem;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.sign-in-mobile,
.settings-mobile,
.mobile-settings-account,
.mobile-settings-signout {
  display: none;
}

@media (min-width: 561px) {
  .brand .settings-mobile,
  .brand .sign-in-mobile {
    display: none !important;
  }
}

.sidebar-actions,
.user-actions {
  display: grid;
  gap: 0.55rem;
}

.sidebar-actions {
  grid-template-columns: auto 1fr;
  margin-top: auto;
}


.sidebar-actions .sign-in-desktop {
  width: 100%;
}

.sidebar-actions .sync-pill {
  grid-column: 1 / -1;
}

.sync-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--item-bg);
  font-size: 0.78rem;
  font-weight: 800;
}

.sync-pill[data-status="synced"] {
  color: var(--success);
  background: rgba(139, 226, 139, 0.12);
}

.sync-pill[data-status="saving"] {
  color: var(--gold);
  background: rgba(242, 200, 107, 0.12);
}

.sync-pill[data-status="local"] {
  color: var(--faint);
}

.user-panel {
  display: grid;
  gap: 0.35rem;
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.user-panel strong {
  font-size: 0.98rem;
}

.user-panel span {
  color: var(--muted);
  font-size: 0.84rem;
  overflow-wrap: anywhere;
}

.user-panel button {
  margin-top: 0.45rem;
}

.user-actions {
  grid-template-columns: auto 1fr;
  align-items: center;
  margin-top: 0.45rem;
}

.user-actions button {
  margin-top: 0;
}

.mobile-settings-account {
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.1rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--item-bg);
  padding: 0.85rem;
}

.mobile-settings-account .eyebrow {
  margin-bottom: 0.18rem;
}

.mobile-settings-account strong,
.mobile-settings-account span {
  display: block;
}

.mobile-settings-account span {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.83rem;
  overflow-wrap: anywhere;
}

.nav-tab {
  background: transparent;
  color: var(--muted);
  text-align: left;
  padding: 0.85rem 1rem;
  border-radius: 8px;
  transition: 160ms ease;
}

.nav-tab:hover,
.nav-tab.active {
  background: var(--surface-soft);
  color: var(--text);
}

.main-content {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 2rem;
}

.page-section {
  display: none;
}

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

.section-heading,
.panel-header,
.panel-subhead,
.form-actions,
.timer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading {
  margin-bottom: 1.4rem;
}

.section-heading h2 {
  font-size: clamp(1.8rem, 3vw, 3.1rem);
  letter-spacing: 0;
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.dashboard-grid,
.builder-layout,
.tasks-layout {
  display: grid;
  gap: 1rem;
}

.dashboard-grid {
  grid-template-columns: 1.1fr 0.9fr;
}

.focus-panel,
.overview-panel {
  grid-column: 1 / -1;
}

.builder-layout {
  grid-template-columns: 1fr 0.9fr;
}

.tasks-layout {
  grid-template-columns: 380px 1fr;
  align-items: start;
}

.panel,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

.panel {
  padding: 1.25rem;
}

.stat-card {
  padding: 1.15rem;
}

.stats-grid,
.review-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.weekly-completed-panel {
  margin-top: 1rem;
}

.stat-card strong {
  display: block;
  margin-top: 0.45rem;
  font-size: 2rem;
}

.inline-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
  margin: 1rem 0;
}

.input-with-suffix {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--input-bg);
}

.input-with-suffix:focus-within {
  border-color: rgba(112, 214, 195, 0.72);
  box-shadow: 0 0 0 3px rgba(112, 214, 195, 0.14);
}

.input-with-suffix input {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.input-with-suffix input:focus {
  border: 0;
  box-shadow: none;
}

.input-with-suffix span {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  padding-right: 0.9rem;
  white-space: nowrap;
}

button,
.inline-form button,
.form-actions button {
  border-radius: 8px;
  background: var(--accent);
  color: #08130f;
  font-weight: 800;
  padding: 0.78rem 1rem;
}

.secondary-button {
  background: var(--surface-soft);
  color: var(--text);
}

.ghost-button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}

.complete-button {
  background: var(--gold);
  color: #171202;
}

.count-pill,
.badge {
  border-radius: 999px;
  padding: 0.32rem 0.62rem;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.focus-list,
.focus-schedule,
.category-list,
.task-picker,
.task-list,
.compact-list,
.schedule-list {
  display: grid;
  gap: 0.7rem;
}

.focus-list {
  padding: 0;
  margin: 0;
  list-style: none;
}

.focus-item,
.focus-plan-note,
.task-card,
.compact-item,
.schedule-item,
.picker-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--item-bg);
}

.focus-item,
.focus-plan-note,
.compact-item,
.schedule-item,
.picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.85rem;
}

.focus-planner {
  margin-top: 1rem;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}

.focus-schedule {
  margin: 0.9rem 0;
}

.focus-plan-note {
  align-items: flex-start;
  justify-content: flex-start;
  color: var(--muted);
  background: rgba(112, 214, 195, 0.08);
}

.focus-planner .secondary-button {
  width: 100%;
}

.focus-item button,
.icon-button {
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  background: var(--surface-soft);
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin: 0.85rem 0;
}

.task-form-panel .form-grid {
  grid-template-columns: 1fr;
}

.category-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
}

.category-control button {
  padding-inline: 0.8rem;
  white-space: nowrap;
}

.helper-text {
  margin: 0.42rem 0 0;
  color: var(--faint);
  font-size: 0.78rem;
}

.category-list {
  margin-top: 1rem;
}

.category-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--item-bg);
  padding: 0.75rem;
}

.category-row.is-preset {
  grid-template-columns: 1fr auto;
}

.category-row strong {
  font-size: 0.95rem;
}

.category-row input {
  padding-block: 0.62rem;
}

.category-row button {
  padding: 0.62rem 0.78rem;
  white-space: nowrap;
}

.time-estimate-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.time-estimate-control select {
  width: auto;
  min-width: 8.2rem;
}

.field-label {
  display: block;
  margin: 0.9rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.form-actions {
  margin-top: 1.2rem;
}

.overview-panel #todayTaskList,
#weeklyCompletedTasks {
  margin-top: 1rem;
}

.task-card {
  padding: 1rem;
}

.task-card.complete {
  opacity: 0.62;
}

.task-card.complete .task-title {
  text-decoration: line-through;
}

.task-topline,
.task-meta,
.task-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.task-topline {
  justify-content: space-between;
}

.task-title {
  font-weight: 800;
}

.task-meta {
  margin: 0.72rem 0;
  color: var(--muted);
  font-size: 0.87rem;
}

.priority-high {
  color: var(--danger);
}

.priority-medium {
  color: var(--gold);
}

.priority-low {
  color: var(--success);
}

.status-message {
  border-radius: 8px;
  padding: 1rem;
  font-weight: 800;
  margin-bottom: 1rem;
}

.status-message.neutral {
  background: var(--surface-soft);
  color: var(--muted);
}

.status-message.success {
  background: rgba(139, 226, 139, 0.13);
  color: var(--success);
}

.status-message.warning {
  background: rgba(255, 143, 143, 0.14);
  color: var(--danger);
}

.schedule-meter {
  height: 0.8rem;
  border-radius: 999px;
  background: var(--track-bg);
  overflow: hidden;
  margin-bottom: 1rem;
}

.schedule-meter div {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width 180ms ease;
}

.timer-panel {
  max-width: 760px;
  margin: 0 auto;
  text-align: center;
}

.settings-panel {
  max-width: 860px;
}

.settings-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.timer-options {
  display: inline-flex;
  gap: 0.5rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--track-bg);
}

.timer-option {
  background: transparent;
  color: var(--muted);
  min-width: 4rem;
}

.timer-option.active {
  background: var(--accent);
  color: #08130f;
}

.timer-display {
  margin: 1.4rem 0;
  font-size: clamp(4rem, 12vw, 8rem);
  font-weight: 800;
  letter-spacing: 0;
}

.timer-actions {
  justify-content: center;
  flex-wrap: wrap;
}

.recent-sessions {
  margin-top: 1.5rem;
  text-align: left;
}

.empty-state {
  color: var(--faint);
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

@media (max-width: 920px) {
  .app-shell,
  .dashboard-grid,
  .builder-layout,
  .tasks-layout,
  .stats-grid,
  .review-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .brand {
    margin-bottom: 1rem;
  }

  .sign-in-nav-button {
    width: auto;
    margin: 0 0 0 auto;
    padding-inline: 0.9rem;
  }

  .sidebar-actions {
    margin-top: 1rem;
  }

  .settings-desktop {
    display: grid;
  }

  .user-panel {
    margin-top: 1rem;
  }

  .nav-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .main-content,
  .sidebar {
    /* Keep your existing 1rem padding, but add the safe area space to the top and bottom */
    padding: 
      calc(1rem + env(safe-area-inset-top)) 
      1rem 
      calc(1rem + env(safe-area-inset-bottom)) 
      1rem;
  }

  .settings-mobile {
    display: grid !important;
    margin-left: auto;
  }

  .user-actions {
    display: none !important;
  }

  .mobile-settings-signout {
    display: inline-flex;
  }

  body.authenticated .mobile-settings-account {
    display: flex;
  }

  .sign-in-desktop {
    display: none;
  }

  .sign-in-mobile {
    display: inline-flex;
    margin-left: 0;
  }

  .settings-desktop {
    display: none !important;
  }

  .section-heading,
  .panel-header,
  .panel-subhead,
  .form-actions,
  .modal-actions,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .inline-form {
    display: flex;
  }

  .form-grid,
  .settings-grid,
  .category-control,
  .category-row,
  .time-estimate-control,
  .nav-tabs {
    grid-template-columns: 1fr;
  }

  .timer-actions button {
    width: 100%;
  }
}
