:root {
  --bg: #16171A;
  --bg-raised: #1D1F23;
  --text: #E8E6E1;
  --text-dim: #8B8D92;
  --hairline: #2C2E33;
  --brass: #B08D57;
  --brass-dim: #7A6640;
  --olive: #6B7353;
  --danger: #B4553F;
  --mono: 'SF Mono', 'Menlo', ui-monospace, monospace;
  --sans: -apple-system, 'Inter', system-ui, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  height: 100%;
  overscroll-behavior-y: contain;
}

body {
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  padding: 28px 20px 16px;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.topbar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.topbar-actions .text-btn {
  font-size: 13px;
  padding: 4px;
}

.topbar-text h1 {
  font-size: 22px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

.topbar-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--brass);
  margin-top: 2px;
}

.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.login-view[hidden] {
  display: none;
}

.login-box {
  width: 100%;
  max-width: 340px;
}

.login-box h1 {
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 8px;
  text-align: center;
}

.login-sub {
  font-size: 14px;
  color: var(--text-dim);
  text-align: center;
  margin: 0 0 24px;
}

.login-box .field-input {
  margin-bottom: 12px;
}

.login-btn {
  width: 100%;
}

.login-status {
  font-size: 13px;
  color: var(--brass);
  text-align: center;
  margin-top: 14px;
  min-height: 16px;
}

.otp-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.otp-row .field-input {
  flex: 1;
  margin-bottom: 0;
}

.view {
  padding: 16px 20px 100px;
  min-height: 100vh;
}

#view-list {
  padding-bottom: 160px;
}

.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 20px;
  padding: 16px 0 20px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 20px;
}

.stat {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: var(--mono);
  font-size: 22px;
  color: var(--brass);
}

.stat-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.section-label {
  font-size: 13px;
  color: var(--text-dim);
  margin: 20px 0 10px;
}

.session-list, .shot-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.type-stats-list {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
}

.type-stats-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
}

.type-stats-name {
  color: var(--text);
}

.type-stats-values {
  display: flex;
  gap: 14px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--brass);
}

.session-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--hairline);
}

.session-item-main {
  display: flex;
  flex-direction: column;
}

.session-program {
  font-size: 16px;
  font-weight: 500;
}

.session-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.session-score {
  font-family: var(--mono);
  font-size: 20px;
  color: var(--brass);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-sub {
  font-size: 13px;
  margin-top: 4px;
}

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--brass);
  color: #16171A;
  border: none;
  font-size: 28px;
  line-height: 1;
  font-weight: 400;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  z-index: 60;
}

.fab:active { background: var(--brass-dim); }

.subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0 16px;
  border-bottom: 1px solid var(--hairline);
  margin-bottom: 16px;
}

.subbar-title {
  font-size: 16px;
  font-weight: 600;
}

.text-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  padding: 6px 4px;
}

.text-btn-primary { color: var(--brass); font-weight: 600; }
.text-btn-danger { color: var(--danger); }

.form-block {
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.field-input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--text);
  font-size: 16px;
  padding: 10px 12px;
  font-family: var(--sans);
}

.section-divider {
  height: 1px;
  background: var(--hairline);
  margin: 24px 0 4px;
}

.shot-entry {
  display: flex;
  gap: 8px;
  align-items: center;
}

.center-ten-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.center-ten-label input[type="checkbox"] {
  accent-color: var(--brass);
  width: 16px;
  height: 16px;
}

.center-ten-badge {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--brass);
  border: 1px solid var(--brass-dim);
  border-radius: 4px;
  padding: 1px 4px;
  margin-left: 4px;
}

.shot-position { flex: 1; }

.score-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 4px 10px;
}

.stepper-btn {
  background: none;
  border: none;
  color: var(--brass);
  font-size: 18px;
  width: 24px;
  height: 32px;
}

.score-value {
  font-family: var(--mono);
  font-size: 16px;
  min-width: 20px;
  text-align: center;
}

.add-shot-btn {
  background: var(--olive);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
}

.plott-add-btn {
  width: 100%;
  margin-top: 4px;
}

.shot-item {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
  font-size: 14px;
}

.shot-subtotal {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
  padding: 4px 0 12px;
  border-bottom: 1px solid var(--hairline);
}

.shot-total {
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--brass);
  text-align: right;
  padding: 12px 0 4px;
}

.shot-item-score {
  font-family: var(--mono);
  color: var(--brass);
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--hairline);
}

.detail-row-label { color: var(--text-dim); font-size: 14px; }
.detail-row-value { font-size: 14px; }

.detail-shots-title {
  font-size: 13px;
  color: var(--text-dim);
  margin: 24px 0 8px;
}

.filter-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}

.chart-wrap {
  width: 100%;
  height: 220px;
  margin-bottom: 8px;
}

.stats-chart {
  width: 100%;
  height: 100%;
  display: block;
}

.stats-chart[hidden] {
  display: none;
}

.table-wrap {
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.stats-table th, .stats-table td {
  text-align: left;
  padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}

.stats-table th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: 12px;
}

.stats-table td.stats-score {
  font-family: var(--mono);
  color: var(--brass);
}

/* Bottom navigation */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  border-top: 1px solid var(--hairline);
  background: var(--bg);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 50;
}

.bottom-nav[hidden] {
  display: none;
}

.bottom-nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  line-height: 1.3;
  padding: 12px 2px;
  white-space: normal;
}

.bottom-nav-btn:active {
  color: var(--brass);
}

/* Add-menu overlay */
.add-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  z-index: 200;
}

.add-menu-overlay[hidden] {
  display: none;
}

.add-menu-box {
  width: 100%;
  background: var(--bg-raised);
  border-top: 1px solid var(--hairline);
  border-radius: 16px 16px 0 0;
  padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.add-menu-btn {
  background: var(--olive);
  color: var(--bg);
  border: none;
  border-radius: 6px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
}

.add-menu-box .text-btn {
  text-align: center;
  padding: 8px;
}

/* Calendar */
.calendar-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.calendar-month-label {
  font-size: 16px;
  font-weight: 600;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
  font-size: 12px;
  color: var(--text-dim);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-shooting { background: var(--brass); }
.dot-competition { background: var(--danger); }
.dot-physical { background: var(--olive); }
.dot-mental { background: #7A93B0; }
.dot-dryfire { background: #9B6B9E; }

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg-raised);
  border: 1px solid transparent;
}

.calendar-day.empty {
  background: none;
}

.calendar-day.selected {
  border-color: var(--brass);
}

.calendar-day-dots {
  display: flex;
  gap: 2px;
  margin-top: 3px;
  height: 6px;
}

.calendar-day-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

/* Goals */
.goal-area {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--hairline);
}

.goal-area-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.goal-area-title {
  font-size: 15px;
  font-weight: 600;
}

.goal-achieved-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.goal-achieved-label input[type="checkbox"] {
  accent-color: var(--brass);
  width: 16px;
  height: 16px;
}

.goal-area .field-input {
  margin-bottom: 8px;
}

.goal-line-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.goal-line-row .field-input {
  flex: 1;
}

.goal-line-row .goal-achieved-label {
  white-space: nowrap;
  flex-shrink: 0;
}

.delete-full-btn {
  width: 100%;
  background: none;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  color: var(--danger);
  font-size: 15px;
  padding: 12px;
  margin-top: 28px;
}

.delete-full-btn:active { background: var(--bg-raised); }

.shot-item-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.shot-move {
  background: none;
  border: none;
  color: var(--brass);
  font-size: 14px;
  width: 22px;
  height: 24px;
  padding: 0;
}

.shot-move:disabled {
  color: var(--hairline);
}

.shot-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  width: 24px;
  height: 24px;
  line-height: 1;
  margin-left: 4px;
}

.file-input-hidden { display: none; }

.image-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.image-thumb {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--hairline);
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-thumb-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 1;
  padding: 0;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.lightbox[hidden] {
  display: none;
}

.lightbox img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
}

/* ---- Trinn 1: profil, sammendrag, poengfelt ---- */
.profile-card {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.profile-field { flex: 1; min-width: 0; }
.profile-field .field-input { width: 100%; box-sizing: border-box; }

.shot-summary {
  font-family: var(--mono);
  font-size: 15px;
  color: var(--brass);
  background: var(--bg-raised);
  border: 1px solid var(--hairline);
  border-radius: 6px;
  padding: 10px 12px;
  margin: 16px 0 0;
}
.shot-summary:empty { display: none; }
.shot-next {
  font-size: 13px;
  color: var(--text-dim);
  margin: 0 0 8px;
}
.score-input { flex: 1; min-width: 0; font-family: var(--mono); }
.klasse-note { font-size: 13px; color: var(--text-dim); }
.shot-series-head {
  font-size: 12px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
  list-style: none;
  margin: 14px 0 4px;
}

.scan-status { font-size: 13px; line-height: 1.45; margin-top: 8px; color: var(--text-dim); }
.scan-status.scan-ok { color: #8FA66B; }
.scan-status.scan-warn { color: #D9A35B; }
.add-shot-btn:disabled { opacity: .5; }

/* ---- Trenermodul ---- */
.fab[hidden] { display: none; }
.viewas-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--brass-dim, #5a4a2d); color: var(--text, #eee);
  padding: 8px 16px; font-size: 13px;
}
.viewas-banner[hidden] { display: none; }
.people-list { list-style: none; margin: 0 0 8px; padding: 0; }
.people-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--hairline);
}
.people-item-main { min-width: 0; flex: 1; cursor: default; }
.people-item-main.clickable { cursor: pointer; }
.people-item-name { font-size: 15px; }
.people-item-sub { font-size: 12px; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; }
.people-item-actions { display: flex; gap: 12px; }
.people-empty { color: var(--text-dim); font-size: 13px; padding: 6px 0; }
.comments-box { margin: 16px 0 0; }
.comments-box:empty { display: none; }
.comments-title {
  font-size: 12px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-dim); margin-bottom: 6px;
}
.comment {
  background: var(--bg-raised); border: 1px solid var(--hairline);
  border-radius: 6px; padding: 8px 10px; margin-bottom: 6px;
}
.comment-meta { font-size: 11px; color: var(--text-dim); margin-bottom: 2px; }
.comment-body { font-size: 14px; white-space: pre-wrap; }
.comment-del { background: none; border: none; color: var(--danger, #c0564a); font-size: 11px; padding: 0 0 0 6px; }
.comment-input { width: 100%; box-sizing: border-box; min-height: 60px; margin: 6px 0; font-family: var(--sans); }
.text-btn[hidden], .delete-full-btn[hidden], .add-shot-btn[hidden] { display: none; }
