/* ============================================================
   AXON — Personal Life OS
   Dark theme matching reference design language
   ============================================================ */

:root {
  /* surface layers */
  --bg: #0f1115;
  --s1: #161a20;
  --s2: #1d232c;
  --s3: #252d38;
  --line: rgba(255, 255, 255, 0.07);
  --line2: rgba(255, 255, 255, 0.12);

  /* text */
  --text: #f0f3f8;
  --muted: #8c97a8;
  --faint: #48545f;

  /* accents */
  --accent: #6ee7c8;
  --accent-dim: rgba(110, 231, 200, 0.15);
  --blue: #7aa2ff;
  --orange: #ffb86b;
  --pink: #f199ff;
  --red: #ff7b7b;
  --green: #7ee787;
  --yellow: #ffe066;

  /* category colors */
  --cat-academic: #7aa2ff;
  --cat-fitness: #7ee787;
  --cat-personal: #ffb86b;
  --cat-social: #f199ff;
  --cat-work: #ffe066;

  --font: Inter, ui-sans-serif, system-ui, -apple-system, "PingFang TC",
    "Microsoft JhengHei", sans-serif;

  /* safe areas */
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
  --sal: env(safe-area-inset-left);
  --sar: env(safe-area-inset-right);

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --tabbar-h: 64px;
}

[data-theme="light"] {
  --bg: #f5f6f8;
  --s1: #ffffff;
  --s2: #f0f2f5;
  --s3: #e6e9ee;
  --line: rgba(0, 0, 0, 0.06);
  --line2: rgba(0, 0, 0, 0.12);
  --text: #1a1f29;
  --muted: #5a6473;
  --faint: #98a1ad;
  --accent-dim: rgba(110, 231, 200, 0.22);
}

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

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
}

input,
textarea,
select {
  font-family: inherit;
  user-select: text;
  -webkit-user-select: text;
}

button {
  font-family: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

/* ===== App shell ===== */
#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-left: var(--sal);
  padding-right: var(--sar);
}

.statusbar-pad {
  height: var(--sat);
  background: var(--bg);
  flex-shrink: 0;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px 8px;
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.5px;
}

.app-header .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 500;
}

.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--s2);
  display: grid;
  place-items: center;
  color: var(--text);
  font-size: 16px;
  transition: transform 0.15s, background 0.15s;
}
.icon-btn:active {
  transform: scale(0.92);
  background: var(--s3);
}

/* ===== Main content area ===== */
main {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 16px calc(var(--tabbar-h) + var(--sab) + 24px);
  -webkit-overflow-scrolling: touch;
}

main::-webkit-scrollbar {
  display: none;
}

.view {
  display: none;
  animation: fadeIn 0.25s ease;
}
.view.active {
  display: block;
}

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

/* ===== Bottom tab bar ===== */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tabbar-h) + var(--sab));
  padding-bottom: var(--sab);
  padding-left: var(--sal);
  padding-right: var(--sar);
  background: rgba(15, 17, 21, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}
[data-theme="light"] .tabbar {
  background: rgba(255, 255, 255, 0.85);
}

.tab {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--faint);
  font-size: 10px;
  font-weight: 500;
  transition: color 0.15s;
}
.tab i {
  font-size: 20px;
}
.tab.active {
  color: var(--accent);
}
.tab:active {
  opacity: 0.6;
}

/* ===== Cards ===== */
.card {
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}
.card-lg {
  padding: 20px;
  border-radius: var(--radius-lg);
}
.card h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 0 0 12px;
}
.card h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 4px;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin: 18px 4px 10px;
}

/* ===== Buttons ===== */
.btn {
  padding: 11px 18px;
  border-radius: 12px;
  background: var(--s2);
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s, background 0.15s;
}
.btn:active {
  transform: scale(0.96);
}
.btn-primary {
  background: var(--accent);
  color: #08231c;
}
.btn-primary:active {
  background: #58c8ac;
}
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line2);
}
.btn-danger {
  background: rgba(255, 123, 123, 0.12);
  color: var(--red);
}
.btn-block {
  width: 100%;
}
.btn-sm {
  padding: 7px 12px;
  font-size: 13px;
  border-radius: 9px;
}

/* ===== FAB ===== */
.fab {
  position: fixed;
  right: 20px;
  bottom: calc(var(--tabbar-h) + var(--sab) + 18px);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  color: #08231c;
  font-size: 24px;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 30px rgba(110, 231, 200, 0.25),
    0 4px 10px rgba(0, 0, 0, 0.3);
  z-index: 50;
  transition: transform 0.15s;
}
.fab:active {
  transform: scale(0.9);
}

/* ===== Form inputs ===== */
.form-group {
  margin-bottom: 14px;
}
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.input,
.textarea,
.select {
  width: 100%;
  padding: 12px 14px;
  background: var(--s2);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
}
.input:focus,
.textarea:focus,
.select:focus {
  border-color: var(--accent);
  background: var(--s2);
}
.textarea {
  min-height: 80px;
  resize: vertical;
  font-family: inherit;
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238c97a8' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--s2);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  border: 1px solid var(--line);
  transition: all 0.15s;
}
.chip.active {
  background: var(--accent-dim);
  color: var(--accent);
  border-color: var(--accent);
}
.chip:active {
  transform: scale(0.95);
}

/* ===== List items ===== */
.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  transition: background 0.15s;
}
.list-item:active {
  background: var(--s2);
}
.list-item .li-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--s2);
  display: grid;
  place-items: center;
  font-size: 16px;
  flex-shrink: 0;
}
.list-item .li-body {
  flex: 1;
  min-width: 0;
}
.list-item .li-title {
  font-weight: 500;
  font-size: 15px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.list-item .li-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}
.list-item .li-action {
  flex-shrink: 0;
  color: var(--faint);
}

/* checkbox style */
.check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--line2);
  display: grid;
  place-items: center;
  font-size: 12px;
  color: transparent;
  transition: all 0.15s;
  flex-shrink: 0;
}
.check.done {
  background: var(--accent);
  border-color: var(--accent);
  color: #08231c;
}

.task-item.done .li-title {
  text-decoration: line-through;
  color: var(--muted);
}

/* category dot */
.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* priority badge */
.badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.badge-urgent { background: rgba(255, 123, 123, 0.15); color: var(--red); }
.badge-high   { background: rgba(255, 184, 107, 0.15); color: var(--orange); }
.badge-medium { background: rgba(122, 162, 255, 0.15); color: var(--blue); }
.badge-low    { background: rgba(140, 151, 168, 0.15); color: var(--muted); }

/* ===== Stats grid ===== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.stat {
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}
.stat .stat-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}
.stat .stat-value {
  font-size: 24px;
  font-weight: 700;
  margin-top: 4px;
  letter-spacing: -0.5px;
}
.stat .stat-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

/* ===== Modal / Sheet ===== */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  display: none;
  opacity: 0;
  transition: opacity 0.25s;
}
.sheet-backdrop.open {
  display: block;
  opacity: 1;
}

.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--s1);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 8px 20px calc(var(--sab) + 24px);
  z-index: 201;
  max-height: 88vh;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  border-top: 1px solid var(--line2);
}
.sheet.open {
  transform: translateY(0);
}
.sheet-handle {
  width: 38px;
  height: 4px;
  background: var(--line2);
  border-radius: 999px;
  margin: 8px auto 16px;
}
.sheet h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 16px;
}
.sheet-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}
.sheet-actions .btn {
  flex: 1;
}

/* ===== Calendar ===== */
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.cal-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.3px;
}
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 14px;
}
.cal-dow {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  padding: 4px 0;
  text-transform: uppercase;
}
.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--s1);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  gap: 2px;
  position: relative;
  transition: background 0.15s;
}
.cal-day.other {
  opacity: 0.3;
}
.cal-day.today {
  background: var(--accent);
  color: #08231c;
  font-weight: 700;
  border-color: var(--accent);
}
.cal-day.selected {
  border-color: var(--accent);
  background: var(--accent-dim);
}
.cal-day:active {
  background: var(--s2);
}
.cal-day .dots {
  position: absolute;
  bottom: 4px;
  display: flex;
  gap: 2px;
}
.cal-day .dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
}

/* ===== Empty state ===== */
.empty {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
}
.empty i {
  font-size: 40px;
  color: var(--faint);
  margin-bottom: 12px;
  display: block;
}
.empty .empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.empty .empty-sub {
  font-size: 13px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: calc(var(--sat) + 16px);
  left: 50%;
  transform: translate(-50%, -120%);
  background: var(--s3);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  z-index: 300;
  border: 1px solid var(--line2);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.toast.show {
  transform: translate(-50%, 0);
}

/* ===== Timer display ===== */
.timer-display {
  font-size: 64px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
  text-align: center;
  margin: 20px 0;
}
.timer-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* progress ring container */
.ring-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto;
}
.ring-wrap svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}
.ring-wrap .ring-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
}

/* macros bar */
.macro-bar {
  display: flex;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--s2);
  margin: 8px 0;
}
.macro-bar div {
  height: 100%;
}

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

/* segmented control */
.segmented {
  display: flex;
  background: var(--s2);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}
.segmented button {
  flex: 1;
  padding: 8px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-radius: 8px;
  transition: all 0.15s;
}
.segmented button.active {
  background: var(--s3);
  color: var(--text);
}

/* swipe-to-delete hint */
.swipe-row {
  position: relative;
  overflow: hidden;
}

/* setting list */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--s1);
  border-bottom: 1px solid var(--line);
}
.setting-row:first-child {
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
}
.setting-row:last-child {
  border-bottom: none;
  border-bottom-left-radius: var(--radius);
  border-bottom-right-radius: var(--radius);
}
.setting-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 14px;
}
.setting-row .label {
  font-weight: 500;
}
.setting-row .value {
  color: var(--muted);
  font-size: 14px;
}

/* switch */
.switch {
  width: 46px;
  height: 28px;
  background: var(--s3);
  border-radius: 999px;
  position: relative;
  transition: background 0.2s;
}
.switch.on {
  background: var(--accent);
}
.switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
.switch.on::after {
  transform: translateX(18px);
}

.hint {
  font-size: 12px;
  color: var(--muted);
  padding: 4px 4px 12px;
  line-height: 1.5;
}

/* horizontal scroll */
.h-scroll {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin: 0 -16px;
  padding-left: 16px;
  padding-right: 16px;
  scrollbar-width: none;
}
.h-scroll::-webkit-scrollbar { display: none; }
.h-scroll > * {
  flex-shrink: 0;
}

/* habit dot grid (streak heatmap) */
.streak-row {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 4px;
  margin-top: 8px;
}
.streak-cell {
  aspect-ratio: 1;
  background: var(--s2);
  border-radius: 3px;
}
.streak-cell.done {
  background: var(--accent);
}

/* greet hero */
.hero {
  padding: 6px 4px 14px;
}
.hero .greet {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.hero .date {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
  font-weight: 500;
}

/* small spinner */
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--line2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* flashcard flip */
.flashcard {
  perspective: 1000px;
  height: 220px;
  margin-bottom: 16px;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
}
.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}
.flashcard-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: var(--s1);
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  padding: 24px;
  display: grid;
  place-items: center;
  text-align: center;
  font-size: 18px;
  font-weight: 500;
}
.flashcard-face.back {
  transform: rotateY(180deg);
  background: var(--s2);
}

/* code/formula display */
.snippet-content {
  background: var(--s2);
  border-radius: 10px;
  padding: 12px;
  font-family: ui-monospace, "SF Mono", monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--accent);
  margin-top: 8px;
  overflow-x: auto;
}

.muted { color: var(--muted); }
.small { font-size: 12px; }
.bold { font-weight: 700; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* ===== AI Chat ===== */
#view-ai {
  padding-bottom: 120px; /* extra space for sticky input */
}

#chat-messages {
  padding-bottom: 8px;
}

/* Center tab AI button highlight */
.tab[data-view="ai"].active span:first-child {
  box-shadow: 0 6px 24px rgba(110,231,200,.5);
}

/* Typing cursor animation */
.typing-cursor::after {
  content: "▋";
  animation: blink 0.8s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ===== Inbox urgency border ===== */
.inbox-urgent { border-left: 3px solid var(--red) !important; }
.inbox-soon   { border-left: 3px solid var(--yellow) !important; }
.inbox-fyi    { border-left: 3px solid var(--green) !important; }

/* ===== Settings pref group ===== */
.setting-row[style*="flex-direction:column"] {
  padding: 14px 16px;
  gap: 8px;
}

/* ===== Canvas import ===== */
.canvas-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  line-height: 1.5;
}
.canvas-step:last-child { border-bottom: none; }
.canvas-step-num {
  width: 22px; height: 22px;
  background: var(--accent);
  color: #08231c;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
