/* Treningslogg — appens stilark, bygget på Kystlys-komponentmønstrene. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  color: var(--ink);
  font-family: var(--font-sans);
  background: var(--surface);
  -webkit-tap-highlight-color: transparent;
}

#app { min-height: 100%; }

.kl-page-wash {
  background:
    radial-gradient(130% 55% at 20% 0%, color-mix(in srgb, var(--accent-warm) 10%, transparent), transparent 60%),
    radial-gradient(100% 50% at 90% 15%, color-mix(in srgb, var(--accent) 8%, transparent), transparent 55%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  background-attachment: fixed;
  min-height: 100%;
}

a { color: inherit; }

/* ---------------------------------------------------------------- Layout */
.screen {
  max-width: 600px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) 100px;
}

.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); margin-bottom: var(--space-5);
}
.page-header .eyebrow { color: var(--accent); display: block; margin-bottom: 2px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--surface); border-top: 1px solid var(--line);
  display: flex; justify-content: space-around;
  padding: 6px max(6px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom));
}
.tabbar button {
  background: none; border: none; cursor: pointer; color: var(--ink-dim);
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 10px; border-radius: var(--radius-sm); font-family: var(--font-mono);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
}
.tabbar button .icon { font-size: 19px; line-height: 1; }
.tabbar button.active { color: var(--accent); }

/* ---------------------------------------------------------------- Card */
.card {
  background: var(--surface); border-radius: var(--radius-md);
  box-shadow: var(--shadow-resting); padding: var(--space-4);
  display: flex; flex-direction: column; gap: var(--space-2);
}
.card + .card { margin-top: var(--space-4); }
.card-list { display: flex; flex-direction: column; gap: var(--space-4); }
.card.tappable { cursor: pointer; }

/* ---------------------------------------------------------------- Button */
button.primary, a.primary {
  background: var(--accent); color: var(--on-accent); border: none;
  padding: 13px 22px; border-radius: var(--radius-md); cursor: pointer;
  font-family: var(--font-sans); font-size: 15px; font-weight: 600;
  text-align: center; text-decoration: none; display: inline-block;
}
button.primary:disabled { opacity: 0.55; cursor: default; }
button.ghost, a.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--ink-dim);
  padding: 13px 18px; border-radius: var(--radius-md); cursor: pointer;
  font-family: var(--font-sans); font-size: 15px; font-weight: 600;
  text-decoration: none; display: inline-block; text-align: center;
}
button.danger-ghost {
  background: transparent; border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger); padding: 13px 18px; border-radius: var(--radius-md); cursor: pointer;
  font-family: var(--font-sans); font-size: 15px; font-weight: 600;
}
button.icon-btn {
  background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  width: 40px; height: 40px; border-radius: var(--radius-md); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  box-shadow: var(--shadow-resting);
}
.btn-row { display: flex; gap: var(--space-3); }
.btn-row button { flex: 1; }

.fab {
  position: fixed; right: var(--space-5); bottom: calc(80px + env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: var(--on-accent); border: none; box-shadow: var(--shadow-floating);
  font-size: 26px; cursor: pointer; z-index: 41;
}

.opt { padding: 7px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); color: var(--ink-dim); cursor: pointer; background: transparent; font-family: var(--font-mono); font-size: 13px; }
.opt.selected { background: var(--accent-dim); border-color: var(--accent-dim); color: var(--on-accent); }
.opt-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }

/* ---------------------------------------------------------------- Input */
.field { margin-bottom: var(--space-4); }
.field label { color: var(--ink-dim); margin-bottom: 6px; display: block; }
input, textarea, select {
  font-family: var(--font-sans); background: var(--surface-alt); border: 1px solid var(--line);
  color: var(--ink); border-radius: var(--radius-md); padding: 11px 14px; font-size: 15px;
  width: 100%; box-sizing: border-box; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent-dim); }
textarea { min-height: 72px; resize: vertical; line-height: 1.5; }
.field-inline { display: flex; align-items: center; gap: var(--space-2); }
.numfield { text-align: center; font-family: var(--font-mono); font-size: 18px; padding: 10px 6px; }

/* ---------------------------------------------------------------- Badge */
.status { padding: 4px 10px; border-radius: var(--radius-full); display: inline-flex; align-items: center; gap: 5px; }
.status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.styrke, .status.pagar { background: color-mix(in srgb, var(--accent-warm) 16%, transparent); color: var(--accent-warm); }
.status.kondisjon { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.status.fullfort { background: color-mix(in srgb, var(--success) 16%, transparent); color: var(--success); }
.status.idle { background: color-mix(in srgb, var(--ink-dim) 16%, transparent); color: var(--ink-dim); }
.meta { color: var(--ink); background: var(--badge-bg); border: 1px solid var(--badge-border); padding: 4px 10px; border-radius: var(--radius-full); backdrop-filter: blur(6px); display: inline-flex; align-items: center; gap: 5px; }

/* -------------------------------------------------------------- Toast */
#toast-host { position: fixed; left: 0; right: 0; bottom: 90px; display: flex; justify-content: center; z-index: 60; pointer-events: none; }
.toast {
  background: var(--surface-alt); color: var(--ink); padding: 11px 20px; border-radius: var(--radius-full);
  border: 1px solid var(--line); display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--font-mono); font-size: 13px; box-shadow: var(--shadow-resting);
  animation: toast-in 0.2s ease-out;
}
@keyframes toast-in { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform:none; } }

/* --------------------------------------------------------- BottomSheet */
.sheet-scrim {
  position: fixed; inset: 0; background: var(--scrim-strong); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  width: 100%; max-width: 480px; background: var(--surface);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: var(--space-5);
  max-height: 88vh; overflow-y: auto;
  animation: sheet-up 0.22s ease-out;
  padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom));
}
@keyframes sheet-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
.sheet-title { margin-bottom: var(--space-4); }

/* ------------------------------------------------------------ EmptyState */
.empty { text-align: center; color: var(--ink-dim); padding: 48px 24px; line-height: 1.7; }
.empty .glyph { font-size: 34px; opacity: 0.55; margin-bottom: 12px; }
.empty strong { color: var(--ink); display: block; margin-bottom: 6px; }

/* ------------------------------------------------------------ SettingsRow */
.group-title { color: var(--ink-dim); margin-bottom: 8px; padding-left: 2px; }
.row-group { display: flex; flex-direction: column; gap: 10px; margin-bottom: var(--space-5); }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface); border: none; cursor: pointer;
  padding: 13px 14px; border-radius: var(--radius-md); box-shadow: var(--shadow-resting);
  color: inherit; font-family: var(--font-sans); font-size: 14.5px;
}
.row-icon { font-size: 18px; flex: 0 0 auto; width: 24px; text-align: center; }
.row-text { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.row-sub { color: var(--ink-dim); }
.row-arrow { color: var(--ink-dim); flex: 0 0 auto; }

/* -------------------------------------------------------------- Set row */
.set-row { display: grid; grid-template-columns: 28px 1fr 1fr 1fr 32px; gap: var(--space-2); align-items: center; padding: var(--space-2) 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: none; }
.set-row .set-num { color: var(--ink-dim); font-family: var(--font-mono); font-size: 13px; text-align: center; }
.set-row.warmup .set-num { color: var(--accent-warm); }
.set-row input { padding: 8px 6px; text-align: center; font-family: var(--font-mono); }
.set-row .rm-set { background: none; border: none; color: var(--ink-dim); cursor: pointer; font-size: 16px; }

/* -------------------------------------------------------------- Loading */
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center-pad { display: flex; align-items: center; justify-content: center; padding: 60px 0; }

/* -------------------------------------------------------------- Rest timer */
.rt-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); padding: var(--space-3) 0; }
.rt-ring { position: relative; width: 200px; height: 200px; }
.rt-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.rt-track { fill: none; stroke: var(--line); stroke-width: 8; }
.rt-progress { fill: none; stroke: var(--accent); stroke-width: 8; stroke-linecap: round; transition: stroke-dashoffset 0.2s linear, stroke 0.2s; }
.rt-progress.rt-low { stroke: var(--danger); }
.rt-time { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-family: var(--font-display); font-size: 40px; font-weight: 700; color: var(--ink); }
.rt-presets { display: flex; gap: var(--space-2); flex-wrap: wrap; justify-content: center; }
.rt-controls { width: 100%; max-width: 320px; }
.rt-done-flash { animation: rt-flash 0.9s ease; }
@keyframes rt-flash { 0%, 100% { background: transparent; } 30% { background: color-mix(in srgb, var(--success) 18%, transparent); border-radius: var(--radius-md); } }

.offline-pill {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: var(--accent-warm); color: var(--on-accent); font-family: var(--font-mono);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; padding: 6px 14px;
  border-radius: var(--radius-full); z-index: 70; box-shadow: var(--shadow-resting);
  display: flex; align-items: center; gap: 6px;
}
