:root {
  --bg: #0b1015;
  --bg-elevated: #121922;
  --bg-soft: #1a2330;
  --border: rgba(255, 255, 255, 0.08);
  --text: #edf2f7;
  --muted: #8b98a9;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  --radius: 22px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color-scheme: dark;
  background:
    radial-gradient(circle at top left, rgba(31, 111, 235, 0.18), transparent 28%),
    radial-gradient(circle at top right, rgba(82, 196, 26, 0.12), transparent 26%),
    linear-gradient(180deg, #091017 0%, #0b1015 100%);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
}

body {
  padding: 24px 16px 120px;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(100%, 480px);
  margin: 0 auto;
  display: grid;
  gap: 10px;
}

.topbar,
.section-header,
.modal-header,
.habit-card-header,
.detail-actions,
.archived-item,
.stats-grid,
.empty-actions,
.progress-row,
.picker-row,
.field-grid,
.header-actions,
.form-section .section-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar,
.detail-actions,
.section-header,
.modal-header,
.habit-card-header,
.progress-row,
.archived-item,
.reminder-row {
  justify-content: space-between;
}

.eyebrow,
.caption {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.tagline {
  margin-top: 6px;
  color: var(--muted);
}

.card {
  position: relative;
  background: rgba(18, 25, 34, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.empty-state,
.archived-panel,
.stat-card {
  padding: 18px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr;
  margin-bottom: 10px;
}

.stat-card {
  min-height: 108px;
  display: grid;
  gap: 8px;
}

.stat-card strong {
  font-size: 2rem;
}

.header-actions {
  justify-content: flex-end;
  gap: 10px;
}

.install-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, #0f766e, #14b8a6);
  color: #ecfeff;
  box-shadow: 0 20px 40px rgba(15, 118, 110, 0.28);
}

.install-banner-btn {
  border: 0;
  border-radius: 14px;
  padding: 10px 14px;
  background: rgba(236, 254, 255, 0.18);
  color: #f0fdfa;
  font: inherit;
  font-weight: 700;
}

.primary-btn,
.ghost-btn,
.segmented-btn,
.picker-preview,
.month-chip {
  border: 0;
  border-radius: 16px;
  padding: 12px 14px;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-btn {
  background: linear-gradient(135deg, #f5a623, #ff6d2d);
  color: #111;
  font-weight: 700;
}

.primary-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.ghost-btn,
.segmented-btn,
.picker-preview,
.month-chip {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--border);
}

.ghost-btn.warn-outline {
  color: #ff9f1c;
  border-color: rgba(255, 159, 28, 0.6);
  background: rgba(255, 159, 28, 0.08);
}

.ghost-btn.small {
  padding: 10px 12px;
}

.ghost-btn.danger {
  color: #ff8c8c;
}

.segmented {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
}

.segmented-btn.active,
.month-chip.active {
  background: rgba(255, 255, 255, 0.16);
}

.habit-list,
.archived-list,
.reminder-list {
  display: grid;
  gap: 10px;
}

.habit-card {
  padding: 18px;
  overflow: hidden;
  cursor: pointer;
}

.habit-card {
  margin-bottom: 0;
}

.habit-card > * {
  position: relative;
  z-index: 1;
}

.card-action-control {
  position: relative;
  z-index: 2;
}

.habit-meta,
.detail-title {
  display: flex;
  align-items: center;
  gap: 14px;
}

.icon-tile {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.icon-tile.mini,
.icon-preview.small {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  font-size: 1rem;
}

.habit-card-actions,
.empty-actions,
.detail-actions-right {
  display: flex;
  gap: 10px;
}

.action-btn {
  min-width: 48px;
}

.progress-row {
  margin: 14px 0 10px;
  color: var(--muted);
}

.progress-row strong {
  color: var(--text);
}

.heatmap {
  display: grid;
  gap: 4px;
}

.compact-heatmap {
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.detail-heatmap {
  grid-template-columns: repeat(31, minmax(0, 1fr));
}

.heat-cell {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.heat-cell.today {
  outline: 1px solid rgba(255, 255, 255, 0.8);
  outline-offset: 1px;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  display: grid;
  gap: 14px;
}

.empty-icon {
  width: 74px;
  height: 74px;
  margin: 0 auto;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.06);
  display: grid;
  place-items: center;
  font-size: 2rem;
}

.habit-card h3 {
  margin-bottom: 4px;
}

.habit-card p,
.muted,
.caption {
  color: var(--muted);
}

.archived-item {
  padding: 14px 0;
  border-top: 1px solid var(--border);
}

.archived-item:first-child {
  border-top: 0;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  padding: 24px 16px;
  background: rgba(5, 10, 16, 0.75);
  backdrop-filter: blur(14px);
  overflow-y: auto;
  z-index: 40;
}

.modal-card {
  width: min(100%, 480px);
  margin: 0 auto;
  background: #111923;
  border: 1px solid var(--border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 20px;
}

.form-modal,
.detail-modal,
.confirm-modal {
  display: grid;
  gap: 18px;
}

.confirm-modal {
  width: min(100%, 520px);
}

.confirm-copy {
  display: grid;
  gap: 8px;
}

.form-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.form-column {
  display: grid;
  gap: 18px;
  align-content: start;
}

.visual-column {
  width: 100%;
}

.form-section,
.detail-section,
.section-block {
  display: grid;
  gap: 16px;
}

.inline-form-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
  align-items: start;
}

.inline-form-main,
.inline-form-visual {
  display: grid;
  gap: 16px;
}

.form-section label,
.category-draft label {
  display: grid;
  gap: 8px;
  color: var(--muted);
}

.field-hint {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 13px 14px;
}

.picker-preview {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.icon-preview {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.08);
}

.icon-preview.large {
  width: 132px;
  height: 132px;
  border-radius: 28px;
}

.visual-preview {
  min-height: 180px;
}

.visual-section {
  justify-items: center;
}

.picker-toggle {
  justify-content: center;
}

.color-grid,
.chip-grid,
.category-icon-grid,
.picker-grid,
.month-switcher {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.color-option {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
}

.color-option.selected {
  border-color: #fff;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
}

.chip input {
  display: none;
}

.chip.selected {
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.22), rgba(255, 109, 45, 0.18));
  border-color: rgba(255, 159, 28, 0.65);
  color: #ffd39b;
}

.category-draft {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--border);
}

.icon-only {
  min-width: 46px;
}

.wide {
  width: 100%;
}

.details-block {
  border-top: 1px solid var(--border);
  padding-top: 16px;
  display: grid;
  gap: 18px;
}

.details-block summary {
  cursor: pointer;
  color: var(--text);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

.basic-grid {
  grid-template-columns: 1fr;
}

.section-block + .section-block {
  margin-top: 2px;
}

.habit-list-section {
  margin-top: 10px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.toggle input {
  width: auto;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.search-input {
  margin: 14px 0;
}

.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
}

.picker-item {
  display: grid;
  place-items: center;
  min-height: 74px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.picker-item.selected {
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.18), rgba(255, 109, 45, 0.14));
  border-color: rgba(255, 159, 28, 0.65);
}

.action-btn.neutral {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.03);
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  color: var(--muted);
}

.calendar-cell {
  min-height: 68px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.04);
  padding: 10px 8px;
  display: grid;
  align-content: space-between;
  color: var(--text);
}

.calendar-cell.empty {
  background: transparent;
  border: 0;
}

.inline-visual,
.emoji-mark,
.app-icon {
  display: inline-grid;
  place-items: center;
}

.emoji-lg {
  font-size: 2.1rem;
}

.emoji-md {
  font-size: 1.4rem;
}

.emoji-sm {
  font-size: 1rem;
}

.app-icon-lg {
  width: 44px;
  height: 44px;
}

.app-icon-md {
  width: 24px;
  height: 24px;
}

.app-icon-sm {
  width: 18px;
  height: 18px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 80;
  width: min(calc(100vw - 32px), 480px);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(10, 16, 24, 0.96);
  box-shadow: var(--shadow);
}

option {
  background: #111923;
  color: var(--text);
}

.topbar {
  align-items: flex-start;
  flex-direction: column;
}

.header-actions,
.detail-actions,
.habit-card-header {
  width: 100%;
}

.detail-heatmap {
  grid-template-columns: repeat(18, minmax(0, 1fr));
}

.calendar-cell {
  min-height: 56px;
}

.install-banner {
  left: 50%;
  right: auto;
  bottom: 12px;
  transform: translateX(-50%);
  width: min(calc(100vw - 24px), 480px);
  align-items: flex-start;
  flex-direction: column;
}

.install-banner-btn {
  width: 100%;
}

@media (max-width: 760px) {
  body {
    padding: 16px 12px 120px;
  }

  .install-banner {
    width: min(calc(100vw - 24px), 480px);
  }
}
