/* ===================== APEX KPI APP ===================== */
:root {
  --bg: #07070d;
  --bg-2: #0f0f1a;
  --surface: #14141f;
  --surface-2: #1c1c2b;
  --surface-3: #252538;
  --border: #2a2a3d;
  --border-soft: #1f1f2e;
  --text: #f1f1f7;
  --text-dim: #a0a0b8;
  --text-mute: #6b6b85;
  --accent: #7c5cff;
  --accent-2: #46e1c5;
  --accent-3: #ffb547;
  --grad: linear-gradient(135deg, #7c5cff 0%, #46e1c5 100%);
  --grad-warm: linear-gradient(135deg, #ff6b9d 0%, #ffb547 100%);
  --grad-fire: linear-gradient(135deg, #ff5e3a 0%, #ffb547 100%);
  --success: #46e1c5;
  --warning: #ffb547;
  --danger: #ff5470;
  --shadow: 0 6px 24px rgba(0,0,0,.45);
  --radius: 16px;
  --radius-sm: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior-y: none;
  -webkit-font-smoothing: antialiased;
}
body {
  min-height: 100vh;
  background:
    radial-gradient(900px 500px at 80% -10%, rgba(124,92,255,.18), transparent 60%),
    radial-gradient(700px 400px at -10% 110%, rgba(70,225,197,.10), transparent 60%),
    var(--bg);
  padding-top: calc(var(--safe-top) + 0px);
}
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea {
  font-family: inherit; font-size: 15px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 14px; width: 100%; outline: none;
  transition: border-color .15s, background .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* ===================== HEADER ===================== */
.app-header {
  position: sticky; top: 0; z-index: 30;
  padding: 14px 16px 12px;
  background: rgba(7,7,13,.85);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border-soft);
  padding-top: calc(14px + var(--safe-top));
}
.mode-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 16px; border-radius: 99px;
  background: var(--surface-2); color: var(--text);
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
  transition: all .15s;
}
.mode-toggle:active { transform: scale(.97); }
.mode-toggle .mode-icon { font-size: 14px; line-height: 1; }
.setting-mode-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.setting-text { flex: 1; min-width: 0; }
.setting-name { font-weight: 700; font-size: 15px; }
.setting-desc { font-size: 12px; color: var(--text-dim); margin-top: 3px; line-height: 1.4; }
body.mode-edit .mode-toggle {
  background: var(--grad-warm);
  color: #1a0d00; border-color: transparent;
  box-shadow: 0 4px 14px rgba(255,181,71,.4);
}
.mode-banner {
  display: none;
  margin: 10px -16px -12px;
  padding: 8px 16px;
  background: linear-gradient(90deg, rgba(255,181,71,.18), rgba(255,107,157,.12));
  color: var(--warning);
  font-size: 12px; font-weight: 700;
  text-align: center;
  border-top: 1px solid rgba(255,181,71,.25);
  border-bottom: 1px solid rgba(255,181,71,.25);
}
body.mode-edit .mode-banner { display: block; }
body.mode-use .edit-only { display: none !important; }
body.mode-edit .kpi-card { border-color: rgba(255,181,71,.4); }
body.mode-edit .routine-item { border-color: rgba(255,181,71,.25); }

.week-bar { margin-top: 12px; display: flex; align-items: center; gap: 10px; }
.week-label { font-size: 12px; font-weight: 700; color: var(--text-dim); flex-shrink: 0; }
.week-stats { flex: 1; display: flex; gap: 6px; min-width: 0; }
.week-stat {
  position: relative; flex: 1; min-width: 0;
  background: var(--surface-3);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  overflow: hidden;
}
.week-stat-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: linear-gradient(90deg, rgba(70,225,197,.55), rgba(70,225,197,.65));
  transition: width .6s cubic-bezier(.2,.8,.2,1);
}
.week-stat-lbl { color: var(--text-dim); position: relative; z-index: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-stat-val { color: var(--text); position: relative; z-index: 1; }

/* ===================== MAIN ===================== */
main { padding: 16px 16px 110px; max-width: 720px; margin: 0 auto; }
.tab-panel { display: none; animation: fadeIn .25s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.page-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 4px 0 16px;
}
.page-title h1 { font-size: 26px; }
.date-display { color: var(--text-dim); font-size: 13px; }
.section-title { font-size: 14px; color: var(--text-dim); margin: 22px 0 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

.day-nav {
  display: flex; align-items: center; gap: 8px;
  margin: 0 0 14px;
}
.day-nav-btn {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--surface-2); color: var(--text);
  font-size: 22px; line-height: 1; font-weight: 700;
  border: 1px solid var(--border-soft);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.day-nav-btn:active { transform: scale(.94); background: var(--surface-3); }
.day-nav-today {
  flex: 1;
  padding: 10px 16px; border-radius: 99px;
  background: var(--surface-2); color: var(--text-dim);
  font-size: 13px; font-weight: 700; letter-spacing: .04em;
  border: 1px solid var(--border-soft);
  transition: background .15s, color .15s;
}
.day-nav-today.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.day-nav-today:active { transform: scale(.97); }
.hint-text { color: var(--text-mute); font-size: 13px; margin: -8px 0 14px; }

/* ===================== CARDS ===================== */
.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.card-head h3 { font-size: 15px; }
.muted { color: var(--text-mute); font-size: 12px; }

.hero-card {
  background: var(--grad);
  border: none;
  color: #fff;
  position: relative; overflow: hidden;
}
.hero-card::after {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(circle at 100% 0%, rgba(255,255,255,.18), transparent 50%);
  pointer-events: none;
}
.hero-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; position: relative; }
.hero-stat { text-align: center; }
.hero-num { font-size: 26px; font-weight: 800; line-height: 1.1; }
.hero-lbl { font-size: 11px; opacity: .85; margin-top: 4px; letter-spacing: .04em; }

/* ===================== BUTTONS ===================== */
.btn-primary {
  background: var(--grad); color: #fff;
  padding: 10px 18px; border-radius: var(--radius-sm);
  font-weight: 700; font-size: 14px;
  box-shadow: 0 4px 14px rgba(124,92,255,.35);
  transition: transform .1s, box-shadow .15s;
}
.btn-primary:active { transform: scale(.96); }
.btn-secondary {
  background: var(--surface-2); color: var(--text);
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px;
  border: 1px solid var(--border);
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-secondary:active { background: var(--surface-3); }
.btn-danger {
  background: rgba(255,84,112,.12); color: var(--danger);
  padding: 10px 16px; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 14px;
  border: 1px solid rgba(255,84,112,.25);
}

/* ===================== KPI WEEK TABLE ===================== */
.kpi-week-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
}
.kpi-week-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;
}
.kpi-week-table th, .kpi-week-table td {
  border: 1px solid var(--border);
  padding: 10px 4px;
  text-align: center;
  vertical-align: middle;
  height: 40px;
  box-sizing: border-box;
  overflow: hidden;
}
.kpi-week-table .kw-cell,
.kpi-week-table .date-cell,
.kpi-week-table .result-cell,
.kpi-week-table .kpi-head { width: auto; }
.routine-week .kpi-week-table { table-layout: fixed; }
.routine-week .kpi-week-table .kw-cell { width: 36%; }
.routine-week .kpi-week-table .result-cell { width: 9%; }
.routine-week .kpi-week-table .day-head {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  padding: 8px 2px;
  line-height: 1.15;
  white-space: nowrap;
}
.routine-week .kpi-week-table .day-head.today { color: var(--accent); }
.routine-week .kpi-week-table .today-col { background: rgba(124,92,255,.06); }
.routine-week .kpi-week-table tbody .routine-head {
  text-align: center;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 700;
  white-space: normal;
  line-height: 1.25;
  word-break: normal;
  overflow-wrap: break-word;
  hyphens: manual;
  background: var(--surface);
  cursor: pointer;
}
.routine-week .kpi-week-table tbody .routine-head:active { background: var(--surface-3); }
.routine-week .kpi-week-table tbody tr.deactivated .routine-head {
  text-decoration: line-through;
  color: var(--text-mute);
}
.routine-week .kpi-week-table tbody tr.deactivated .result-val { color: var(--text-mute); }

@media (max-width: 600px) {
  .kpi-week-table th, .kpi-week-table td {
    height: 32px;
    padding: 4px 3px;
  }
  .kpi-week-table .date-cell { font-size: 11px; }
  .routine-week .kpi-week-table tbody .routine-head {
    padding: 5px 6px;
    font-size: 11px;
    line-height: 1.2;
  }
  .routine-week .kpi-week-table .day-head { padding: 5px 2px; font-size: 11px; }
}
.kpi-week-table thead th {
  background: var(--surface-2);
  font-weight: 700;
  position: sticky; top: 0; z-index: 1;
}
.kpi-week-table .kw-cell { font-size: 12px; letter-spacing: .04em; }
.kpi-week-table .kpi-head {
  font-size: 20px; cursor: default;
  min-width: 44px;
}
body.mode-edit .kpi-week-table .kpi-head { cursor: pointer; }
body.mode-edit .kpi-week-table .kpi-head:active { background: var(--surface-3); }
.kpi-week-table .date-cell {
  font-size: 12px; color: var(--text-dim);
  white-space: nowrap; text-align: center;
  background: var(--surface);
}
.kpi-week-table tr.today .date-cell { color: var(--accent); font-weight: 700; }
.kpi-week-table tr.today td { background: rgba(124,92,255,.05); }
.kpi-week-table tfoot td {
  background: var(--surface-2);
  font-weight: 800;
}
.kpi-week-table tfoot .result-cell { text-align: center; }
.kpi-week-table tfoot .result-val.hit { color: var(--success); }

.kpi-cell { cursor: pointer; transition: background .1s; }
.kpi-cell:active { background: var(--surface-3); }
.kpi-cell.off { cursor: default; }
.cell-check, .cell-skip, .cell-fail, .cell-exclude {
  display: inline-block;
  width: 18px; height: 18px;
  vertical-align: middle;
  position: relative;
  line-height: 18px;
}
.cell-check {
  border: 1.5px solid var(--border);
  border-radius: 4px;
}
.cell-check.done { background: var(--success); border-color: var(--success); }
.cell-check.done::after {
  content: '✓'; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: #07261f; font-weight: 800; font-size: 13px; line-height: 1;
}
.cell-skip::after {
  content: '✕'; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-mute);
  font-weight: 800; font-size: 14px; line-height: 1;
}
.cell-fail::after {
  content: '✕'; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--danger);
  font-weight: 800; font-size: 14px; line-height: 1;
}
.cell-exclude::after {
  content: '✕'; position: absolute; inset: 0;
  display: grid; place-items: center;
  color: var(--text-mute);
  font-weight: 800; font-size: 14px; line-height: 1;
}
.cell-num { font-weight: 700; }
.cell-num.hit { color: var(--success); }
.kpi-cell.editing { padding: 0; background: var(--bg-2); }
.cell-input {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0 4px;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  background: transparent;
  color: var(--text);
  border: 2px solid var(--accent);
  border-radius: 0;
  outline: none;
  box-sizing: border-box;
  -moz-appearance: textfield;
}
.cell-input::-webkit-outer-spin-button,
.cell-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* Today KPI tap-row */
.kpi-today-list { display: flex; flex-direction: column; gap: 10px; }
.kpi-today-row {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  transition: transform .1s;
}
.kpi-today-row:active { transform: scale(.99); }
.kpi-today-row.done { border-color: rgba(70,225,197,.35); background: linear-gradient(180deg, rgba(70,225,197,.06), var(--surface)); }
.kpi-today-row.skipped .kpi-today-name,
.kpi-today-row.skipped .kpi-today-sub { text-decoration: line-through; color: var(--text-mute); }
.kpi-today-row.skipped { opacity: .7; }
.kpi-today-icon {
  width: 38px; height: 38px; border-radius: 10px;
  background: var(--surface-2); display: grid; place-items: center; font-size: 18px;
  flex-shrink: 0;
}
.kpi-today-info { flex: 1; min-width: 0; }
.kpi-today-name { font-weight: 700; font-size: 14px; }
.kpi-today-sub { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.kpi-today-value { font-weight: 700; font-size: 16px; }

/* ===================== TODOS ===================== */
.todo-form { display: flex; gap: 8px; margin-bottom: 14px; }
.todo-form input { flex: 1; }
.todo-tabs {
  display: flex; gap: 8px; margin-bottom: 14px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.todo-tabs .chip { flex-shrink: 0; }
.todo-tab-add {
  font-size: 18px; font-weight: 800;
  padding: 5px 14px;
  background: var(--surface-2);
  color: var(--text-dim);
  border: 1px dashed var(--border);
}
.chip {
  padding: 7px 14px; border-radius: 99px;
  background: var(--surface-2); color: var(--text-dim);
  font-size: 13px; font-weight: 600; border: 1px solid var(--border-soft);
}
.chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.todo-list { display: flex; flex-direction: column; gap: 8px; }
.todo-list.todo-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.todo-list.todo-grid-2 .empty { grid-column: 1 / -1; }
@media (max-width: 420px) {
  .todo-list.todo-grid-2 { gap: 6px; }
  .todo-list.todo-grid-2 .todo-item { padding: 8px 10px; gap: 8px; }
  .todo-list.todo-grid-2 .todo-check { width: 18px; height: 18px; border-width: 2px; }
  .todo-list.todo-grid-2 .todo-check.done::after,
  .todo-list.todo-grid-2 .todo-check.failed::after,
  .todo-list.todo-grid-2 .todo-check.skipped::after { font-size: 12px; }
  .todo-list.todo-grid-2 .todo-text { font-size: 12px; }
}
.todo-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  animation: slideIn .25s ease;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.todo-item.dragging {
  background: var(--surface-2);
  border-color: var(--accent);
  box-shadow: 0 10px 28px rgba(0,0,0,.5);
  transform: scale(1.02);
  z-index: 5;
  position: relative;
  touch-action: none;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
.todo-check {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid var(--border);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: background .15s, border-color .15s;
}
.todo-check.done {
  background: var(--success); border-color: var(--success);
  color: #07261f;
}
.todo-check.done::after { content: '✓'; font-weight: 800; font-size: 14px; }
.todo-check.skipped { border-color: var(--text-mute); }
.todo-check.skipped::after { content: '✕'; font-weight: 800; font-size: 14px; color: var(--text-mute); }
.todo-text { font-size: 14px; word-break: break-word; }
.todo-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.todo-item.state-skipped .todo-text { color: var(--text-mute); text-decoration: line-through; }
.todo-item.state-done { border-color: rgba(70,225,197,.35); }
#weeklyTaskList .todo-check.failed { border-color: var(--danger); }
#weeklyTaskList .todo-check.failed::after { content: '✕'; color: var(--danger); }
#weeklyTaskList .todo-item.state-failed { border-color: rgba(255,84,112,.35); }
#weeklyTaskList .todo-item.state-failed .todo-text { color: var(--text); text-decoration: none; }
.todo-banner {
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
  font-size: 13px; font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}
.todo-banner.soon { color: var(--warning); border-color: rgba(255,181,71,.4); background: rgba(255,181,71,.1); }
.todo-banner.overdue { color: var(--danger); border-color: rgba(255,84,112,.4); background: rgba(255,84,112,.1); }
.todo-del { color: var(--text-mute); padding: 4px 8px; font-size: 18px; }
.todo-del:active { color: var(--danger); }
.todo-deadline {
  display: inline-block;
  align-self: flex-start;
  padding: 2px 8px; border-radius: 99px;
  font-size: 11px; font-weight: 700;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border-soft);
}
.todo-deadline.soon { color: var(--warning); border-color: rgba(255,181,71,.4); background: rgba(255,181,71,.1); }
.todo-deadline.overdue { color: var(--danger); border-color: rgba(255,84,112,.4); background: rgba(255,84,112,.1); }
.todo-deadline.unlimited { color: var(--text-mute); }
.inline-check {
  display: flex !important;
  flex-direction: row !important;
  align-items: center; gap: 8px;
  font-size: 14px !important; color: var(--text) !important;
  cursor: pointer;
}
.inline-check input { width: auto; }
.todo-deadline-wrap {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.todo-deadline-wrap input[type="date"],
.todo-deadline-wrap input[type="time"] { color-scheme: dark; }

/* ===================== ROUTINE SUB-TABS ===================== */
.routine-subtabs {
  display: flex; gap: 8px; margin-bottom: 14px;
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
}
.routine-subtabs .chip { flex-shrink: 0; }
.routine-sub[hidden] { display: none; }

/* ===================== ROUTINES ===================== */
.routine-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.routine-item.done { border-color: rgba(70,225,197,.35); }
.routine-item.done .routine-text { color: var(--text-mute); text-decoration: line-through; }

.routine-edit {
  width: 30px; height: 30px; border-radius: 8px;
  display: grid; place-items: center;
  color: var(--text-mute); font-size: 14px;
}
.routine-edit:active { background: var(--surface-2); color: var(--text); }
.routine-days-hint {
  font-size: 11px; color: var(--text-mute);
  margin-top: 2px; letter-spacing: .04em;
}

.day-chips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-top: 4px; }
.day-chip {
  padding: 11px 0; border-radius: 8px;
  background: var(--surface-2); color: var(--text-dim);
  font-size: 12px; font-weight: 700;
  border: 1px solid var(--border-soft);
}
.day-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.day-shortcuts { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.day-shortcuts .chip { background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border-soft); padding: 6px 11px; }

/* ===================== BODY ===================== */
.inline-form { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-form input { flex: 1; }
.weight-form { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; gap: 8px; margin-bottom: 6px; }
.weight-form input[type="date"] { color-scheme: dark; }
@media (max-width: 380px) {
  .weight-form { grid-template-columns: 1fr 1fr; }
  .weight-form button { grid-column: 1 / -1; }
}
.weight-list-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 14px; font-size: 13px; color: var(--text-dim); font-weight: 600;
}
.weight-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.weight-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-soft);
}
.weight-row .w-date { flex: 1; font-size: 13px; color: var(--text-dim); }
.weight-row .w-val { font-weight: 700; font-size: 15px; }
.weight-row button { color: var(--text-mute); font-size: 18px; padding: 4px 8px; }
.weight-row button:active { color: var(--danger); }
.chart-wrap { position: relative; height: 220px; margin-top: 8px; }
.range-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 4px 0 6px; }
.range-btn {
  padding: 8px 0; border-radius: 8px;
  background: var(--surface-2); color: var(--text-dim);
  font-size: 12px; font-weight: 700;
  border: 1px solid var(--border-soft);
}
.range-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.photo-upload {
  display: block; padding: 18px; text-align: center;
  background: var(--surface-2); border: 2px dashed var(--border);
  border-radius: var(--radius-sm); color: var(--text-dim);
  font-weight: 600; font-size: 14px;
  cursor: pointer; margin-bottom: 12px;
  transition: border-color .15s, color .15s;
}
.photo-upload:active { border-color: var(--accent); color: var(--accent); }
.photo-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.photo-item {
  position: relative; aspect-ratio: 1;
  border-radius: var(--radius-sm); overflow: hidden;
  background: var(--surface-2);
}
.photo-item img { width: 100%; height: 100%; object-fit: cover; }
.photo-date {
  position: absolute; bottom: 0; left: 0; right: 0;
  padding: 4px 6px; font-size: 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.75));
  color: #fff; font-weight: 600;
}
.photo-del {
  position: absolute; top: 4px; right: 4px;
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff;
  display: grid; place-items: center; font-size: 14px;
}

/* ===================== STATS ===================== */
.select-input { margin-bottom: 8px; }
.settings-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.settings-row .btn-secondary, .settings-row .btn-danger { flex: 1; justify-content: center; display: inline-flex; }

/* ===================== ACHIEVEMENTS ===================== */
.achievement-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.achievement {
  aspect-ratio: 1; border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border-soft);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 8px; text-align: center;
  opacity: .35;
  filter: grayscale(.8);
  transition: all .3s;
}
.achievement.unlocked {
  opacity: 1; filter: none;
  background: linear-gradient(135deg, rgba(124,92,255,.15), rgba(70,225,197,.10));
  border-color: rgba(124,92,255,.4);
}
.achievement-icon { font-size: 28px; margin-bottom: 4px; }
.achievement-name { font-size: 11px; font-weight: 700; }
.achievement-desc { font-size: 9px; color: var(--text-mute); margin-top: 2px; }

/* ===================== TABBAR ===================== */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(15,15,26,.95);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-soft);
  padding: 6px 4px calc(6px + var(--safe-bottom));
}
.tab-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 6px 2px; color: var(--text-mute);
  font-size: 10px; font-weight: 600;
  border-radius: 10px; transition: color .15s, background .15s;
}
.tab-btn.active { color: var(--accent); background: rgba(124,92,255,.12); }
.tab-icon { font-size: 19px; line-height: 1; }
.tab-label { letter-spacing: .02em; }

/* ===================== MODAL ===================== */
.modal {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,.6);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .2s;
}
.modal[hidden] { display: none !important; }
.toast[hidden] { display: none !important; }
.modal-content {
  width: 100%; max-width: 520px;
  background: var(--bg-2);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(18px + var(--safe-bottom));
  max-height: 92vh; overflow-y: auto;
  animation: slideUp .25s cubic-bezier(.2,.8,.2,1);
}
@media (min-width: 600px) {
  .modal { align-items: center; padding: 20px; }
  .modal-content { border-radius: 20px; border: 1px solid var(--border); }
}
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { font-size: 18px; }
.modal-close {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface-2); display: grid; place-items: center;
  font-size: 22px; line-height: 1; color: var(--text-dim);
}
.modal-form { display: flex; flex-direction: column; gap: 12px; }
.modal-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--text-dim); font-weight: 600;
}
.modal-actions {
  display: flex; gap: 8px; margin-top: 6px;
  justify-content: space-between;
}
.modal-actions .btn-primary, .modal-actions .btn-secondary, .modal-actions .btn-danger {
  flex: 1; padding: 13px; justify-content: center; display: inline-flex; align-items: center;
}

.bool-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.bool-btn {
  padding: 18px; border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--text);
  font-weight: 700; font-size: 15px;
  border: 2px solid var(--border);
  transition: all .15s;
}
.bool-btn.active[data-val="1"] { background: var(--success); color: #07261f; border-color: var(--success); }
.bool-btn.active[data-val="0"] { background: var(--surface-3); color: var(--text-dim); border-color: var(--border); }

/* ===================== TOAST ===================== */
.toast {
  position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 18px; border-radius: 99px;
  font-weight: 600; font-size: 13px;
  box-shadow: 0 8px 30px rgba(0,0,0,.5);
  z-index: 60;
  animation: toastIn .3s cubic-bezier(.2,.8,.2,1);
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.warn { border-color: var(--warning); color: var(--warning); }
@keyframes toastIn {
  from { transform: translate(-50%, 20px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

/* ===================== CONFETTI ===================== */
.confetti-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 70;
}

/* ===================== EMPTY ===================== */
.empty {
  text-align: center; padding: 32px 20px;
  color: var(--text-mute); font-size: 13px;
}
.empty-icon { font-size: 36px; margin-bottom: 8px; opacity: .5; }
