:root {
  --bg:            #f0e8df;
  --surface:       #fdf8f4;
  --surface-2:     #f5ede4;
  --brand:         #5e3521;
  --brand-light:   #7a4a30;
  --accent:        #c4641c;
  --accent-hover:  #a8521a;
  --text:          #1f1209;
  --text-muted:    #7a6458;
  --border:        #ddd0c5;
  --border-light:  #ede5dc;
  --danger:        #c92032;
  --success:       #1a7a3f;
  --radius:        14px;
  --radius-sm:     8px;
  --shadow:        0 2px 8px rgba(31,18,9,0.07);
  --shadow-lg:     0 8px 28px rgba(31,18,9,0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'DM Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Header ───────────────────────────────────── */

header {
  background: var(--brand);
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 16px rgba(0,0,0,0.28);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 10px;
  max-width: 800px;
  margin: 0 auto;
}

.header-logo {
  height: 30px;
  width: auto;
  filter: brightness(0) invert(1);
  opacity: 0.95;
}

header h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.app-footer {
  text-align: center;
  padding: 24px 0 16px;
  font-size: 0.65rem;
  color: var(--text-muted, #aaa);
  opacity: 0.5;
}

.logout-btn {
  margin-left: auto;
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.7);
  border-radius: 6px;
  padding: 5px 9px;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.logout-btn:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

/* ── Nav tabs ─────────────────────────────────── */

nav {
  display: flex;
  max-width: 800px;
  margin: 0 auto;
  border-top: 1px solid rgba(255,255,255,0.12);
}

.tab {
  flex: 1;
  padding: 10px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}

.tab.active {
  color: #fff;
  border-bottom-color: rgba(255,255,255,0.9);
}

/* ── Layout ───────────────────────────────────── */

main {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 12px 80px;
}

.tab-content { display: none; padding: 16px 0; }
.tab-content.active { display: block; }
.hidden { display: none !important; }

/* ── Toolbar ──────────────────────────────────── */

.toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.toolbar button {
  padding: 13px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  text-align: center;
  box-shadow: var(--shadow);
}

.toolbar button:hover  { background: var(--surface-2); border-color: var(--brand-light); }
.toolbar button:active { transform: scale(0.97); }

/* ── Month sections ───────────────────────────── */

.month-section {
  margin-bottom: 6px;
}

.month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-sm);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background 0.15s;
}

.month-header::-webkit-details-marker { display: none; }

.month-section[open] > .month-header {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.month-header:hover { background: var(--brand-light); }

.month-header::after {
  content: '▾';
  font-size: 0.9rem;
  opacity: 0.7;
  transition: transform 0.2s;
  margin-left: 8px;
}

.month-section:not([open]) .month-header::after {
  transform: rotate(-90deg);
}

.month-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.month-count {
  font-size: 0.7rem;
  font-weight: 600;
  opacity: 0.65;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.month-body {
  padding: 8px 0 4px;
}

/* ── Session cards ────────────────────────────── */

.session-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

.session-card h4 {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--brand);
}

.source-badge {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1px solid var(--border);
}

.session-notes {
  font-size: 0.875rem;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 12px;
  padding: 8px 12px;
  background: var(--bg);
  border-left: 3px solid var(--brand);
  border-radius: 0 6px 6px 0;
}

.session-card table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.session-card th {
  text-align: left;
  padding: 5px 8px;
  border-bottom: 1.5px solid var(--border);
  color: var(--text-muted);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.session-card td {
  padding: 7px 8px;
  border-bottom: 1px solid var(--border-light);
}

.session-card tr:last-child td { border-bottom: none; }
.session-card td:first-child { font-weight: 500; }

.session-card td:not(:first-child) {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.session-card .group-label {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--brand);
  padding: 8px 8px 3px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.session-card .group-entry td:first-child {
  padding-left: 20px;
  color: var(--text-muted);
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-light);
}

.card-actions button {
  flex: 1;
  padding: 9px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text);
  transition: background 0.15s;
}

.card-actions button:hover         { background: var(--surface-2); }
.card-actions button.danger        { color: var(--danger); border-color: var(--danger); }
.card-actions button.danger:hover  { background: #fff0f0; }
.card-actions button.complete-btn  { color: var(--success); border-color: var(--success); }
.card-actions button.complete-btn:hover { background: #f0fff5; }

.completed-badge {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  background: #d1fae5;
  color: #065f46;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Modals (bottom sheet on mobile) ─────────── */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(31,18,9,0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}

.modal-content {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 8px 16px 36px;
  width: 100%;
  max-width: 800px;
  max-height: 92vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* Bottom sheet drag handle */
.modal-content::before {
  content: '';
  display: block;
  width: 40px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 4px auto 6px;
  flex-shrink: 0;
}

.modal-content h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.modal-content h4 {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.modal-content label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-content input,
.modal-content textarea,
.modal-content select {
  padding: 11px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  color: var(--text);
  background: var(--bg);
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.modal-content input:focus,
.modal-content textarea:focus,
.modal-content select:focus {
  outline: none;
  border-color: var(--brand);
}

.modal-content textarea { resize: vertical; }

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* ── Buttons ──────────────────────────────────── */

button.primary {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 13px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: background 0.15s, transform 0.1s;
}

button.primary:hover  { background: var(--accent-hover); }
button.primary:active { transform: scale(0.98); }

.btn-close {
  background: transparent;
  border: 1.5px solid var(--border);
  padding: 13px 22px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s;
}

.btn-close:hover { background: var(--surface-2); }

.add-block-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.add-block-actions button {
  padding: 9px 14px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.add-block-actions button:hover {
  background: var(--surface-2);
  border-color: var(--brand-light);
  color: var(--brand);
}

/* ── Entry rows ───────────────────────────────── */

.entry-row {
  display: grid;
  grid-template-columns: 2fr 52px 52px 72px auto auto auto auto;
  gap: 5px;
  align-items: end;
  margin-bottom: 8px;
}

.entry-row input,
.entry-row select { width: 100%; }

.entry-row input {
  padding: 9px 8px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  background: var(--bg);
  color: var(--text);
  -webkit-appearance: none;
}

.entry-row input:focus {
  outline: none;
  border-color: var(--brand);
}

.entry-row .icon-btn {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 9px 7px;
  color: var(--text-muted);
  line-height: 1;
  transition: background 0.15s;
}

.entry-row .icon-btn:hover { background: var(--border); }

.entry-row .remove-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.3rem;
  padding: 5px 4px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.entry-row .remove-btn:hover { opacity: 1; }

/* ── AMRAP / EMOM group blocks ────────────────── */

.group-block {
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 10px;
  overflow: hidden;
}

.group-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--brand);
  color: #fff;
}

.group-type-badge {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: rgba(255,255,255,0.2);
  padding: 3px 10px;
  border-radius: 20px;
}

.group-rounds-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
}

.group-rounds-wrap input {
  width: 52px;
  padding: 4px 8px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
}

.group-rounds-wrap input::placeholder { color: rgba(255,255,255,0.45); }

.group-header-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.group-header-actions button {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  color: #fff;
  cursor: pointer;
  font-size: 0.8rem;
  padding: 4px 8px;
  line-height: 1;
}

.group-header-actions button:hover { background: rgba(255,255,255,0.15); }

.group-header-actions .remove-btn {
  border-color: rgba(255,100,100,0.4);
  color: #ffb3b3;
}

.group-entries { padding: 10px 12px 4px 20px; }

.group-add-entry {
  margin: 4px 12px 10px 20px;
  padding: 7px 14px;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  background: none;
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--brand);
}

.group-add-entry:hover { background: var(--surface-2); }

/* ── Autocomplete ─────────────────────────────── */

.ac-wrapper { position: relative; }

.ac-list {
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 160px;
  overflow-y: auto;
  z-index: 200;
  box-shadow: var(--shadow-lg);
}

.ac-list div {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-light);
}

.ac-list div:last-child { border-bottom: none; }
.ac-list div:hover { background: var(--surface-2); }

/* ── Misc ─────────────────────────────────────── */

#ai-loading, #suggest-loading {
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 500;
  font-style: italic;
  text-align: center;
  padding: 8px;
}

#btn-voice-record {
  width: 100%;
  padding: 14px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.15s;
}

#btn-voice-record:hover { background: var(--brand-light); }

#voice-transcript {
  margin-top: 10px;
  padding: 12px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-muted);
  min-height: 60px;
  border: 1.5px solid var(--border);
}

#suggest-notes-text {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 10px 14px;
  background: var(--bg);
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
}

/* ── Mobile entry row: name on its own row ────── */

@media (max-width: 520px) {
  .entry-row {
    grid-template-columns: 1fr 44px 44px 60px auto auto auto auto;
  }
  .entry-row .ac-wrapper {
    grid-column: 1 / -1;
  }
}

/* ── 1RM Tab ──────────────────────────────────── */

.lift-card {
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.lift-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1.5px solid var(--border-light);
}

.lift-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.lift-best {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.01em;
}

.lift-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.lift-table th {
  text-align: left;
  padding: 6px 10px;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-light);
}

.lift-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.lift-table tr:last-child td { border-bottom: none; }

.lift-date { color: var(--text-muted); font-size: 0.82rem; }

.lift-weight {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.15rem;
  font-weight: 700;
  white-space: nowrap;
}

.lift-unit {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}

.pr-badge {
  display: inline-block;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.6rem;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 6px;
  vertical-align: middle;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lift-trend {
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  width: 28px;
}

.trend-up   { color: var(--success); }
.trend-down { color: var(--danger); }
.trend-flat { color: var(--text-muted); }

.lift-event {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

.lift-delete-btn {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 1.2rem;
  padding: 2px 6px;
  opacity: 0.5;
  transition: opacity 0.15s;
  line-height: 1;
}

.lift-delete-btn:hover { opacity: 1; }

/* ── AI Weekly Program ────────────────────────── */

.weekly-overview {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 16px;
  padding: 12px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent);
}

.weekly-session-block {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  margin-bottom: 14px;
  overflow: hidden;
}

.weekly-session-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-light);
}

.weekly-session-name {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex: 1;
}

.weekly-date-input {
  padding: 6px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  background: var(--bg);
  color: var(--text);
  flex-shrink: 0;
}

.weekly-date-input:focus {
  outline: none;
  border-color: var(--brand);
}

.weekly-session-notes {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 8px 14px 0;
  font-style: italic;
  line-height: 1.4;
}

.weekly-entries { padding: 4px 8px; }

.weekly-add-entry {
  background: none;
  border: none;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.82rem;
  cursor: pointer;
  padding: 8px 14px;
  display: block;
  width: 100%;
  text-align: left;
}

.weekly-add-entry:hover { color: var(--accent-hover); }

/* ── Import Tab ───────────────────────────────── */

.import-phase {
  padding: 16px;
}

.import-intro {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: 18px;
}

.import-url-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.import-url-form input[type="url"] {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.9rem;
  background: var(--surface);
  color: var(--text);
}

.import-url-form input:focus {
  outline: none;
  border-color: var(--brand);
}

.import-loading {
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 6px 0;
  font-style: italic;
}

.import-orm-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 4px;
}

.import-section-title {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}

.import-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 14px;
}

.export-section {
  margin-top: 28px;
  padding: 16px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
}

.btn-export {
  display: inline-block;
  margin-top: 4px;
  padding: 10px 20px;
  background: var(--brand);
  color: #fff;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background 0.15s;
}

.btn-export:hover { background: var(--brand-light); }
.btn-export:disabled { opacity: 0.45; cursor: not-allowed; pointer-events: none; }

.csv-import-form { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.csv-file-label { cursor: pointer; background: var(--surface-2); color: var(--brand); border: 1.5px solid var(--border); }
.csv-file-label:hover { background: var(--border-light); }
.btn-csv-import { border: none; }

.profile-label { display: flex; flex-direction: column; gap: 5px; font-size: 0.875rem; font-weight: 500; color: var(--text-muted); }
.profile-label textarea, .profile-label input[type="date"] { font-family: 'DM Sans', sans-serif; font-size: 0.875rem; padding: 8px 12px; border: 1.5px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); resize: vertical; }
.profile-label textarea:focus, .profile-label input[type="date"]:focus { outline: none; border-color: var(--accent); }

.danger-section { border-color: #f5c6c6; }
.danger-title { color: var(--danger); }
.btn-danger-action {
  margin-top: 4px;
  padding: 10px 20px;
  background: none;
  border: 1.5px solid var(--danger);
  color: var(--danger);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-danger-action:hover { background: var(--danger); color: #fff; }


/* ── Empty state ──────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 16px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* ── Spinner ──────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(94,53,33,0.2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}

/* ── Exercise name truncation ─────────────────── */

.session-card td:first-child {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (min-width: 500px) {
  .session-card td:first-child { max-width: none; }
}

.orm-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border-light);
}

.orm-row:last-child { border-bottom: none; }

.orm-label {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
}

.orm-input-wrap {
  display: flex;
  align-items: center;
  gap: 4px;
}

.orm-input {
  width: 80px;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: right;
  background: var(--bg);
  color: var(--text);
}

.orm-input:focus {
  outline: none;
  border-color: var(--brand);
}

.orm-unit {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
}

.import-week-heading {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding: 16px 16px 8px;
}

.import-session-card {
  background: var(--surface);
  margin: 0 8px 10px;
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.import-session-header {
  padding: 8px 14px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-light);
}

.import-entry-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-light);
}

.import-entry-row:last-child { border-bottom: none; }

.import-entry-info { flex: 1; min-width: 0; }

.import-entry-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.import-entry-detail {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.import-weight-input {
  width: 70px;
  padding: 7px 8px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: right;
  background: var(--bg);
  color: var(--text);
  flex-shrink: 0;
}

.import-weight-input:focus {
  outline: none;
  border-color: var(--brand);
}

.import-weight-input.no-orm {
  opacity: 0.4;
}

.import-rpe-warn {
  color: #e8a030;
  cursor: help;
  font-style: normal;
}

.import-footer {
  position: sticky;
  bottom: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  z-index: 10;
  box-shadow: 0 -4px 16px rgba(31,18,9,0.1);
  margin-top: 16px;
}

.import-footer-count {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.btn-text-link {
  background: none;
  border: none;
  color: var(--accent);
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 12px 16px;
  display: block;
  text-align: center;
  width: 100%;
}

.btn-text-link:hover { color: var(--accent-hover); }

/* ── Desktop overrides ────────────────────────── */

/* ── Load error ────────────────────────────────── */

.load-error {
  color: var(--danger);
  font-size: 0.875rem;
  padding: 12px 0;
}

/* ── AI Clarifications ────────────────────────── */

#ai-clarifications {
  background: #fff8e6;
  border: 1.5px solid #e8c84a;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.clarifications-header {
  font-size: 0.8rem;
  font-weight: 600;
  color: #7a5c00;
  margin-bottom: 6px;
}

#ai-clarifications-list {
  margin: 0;
  padding-left: 18px;
  font-size: 0.82rem;
  color: #5a4200;
  line-height: 1.5;
}

/* ── AI Chat / Feedback ────────────────────────── */

.ai-chat-section {
  margin-top: 16px;
  border-top: 1px solid var(--border-light);
  padding-top: 12px;
}

.ai-chat-history {
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-msg {
  font-size: 0.82rem;
  padding: 6px 10px;
  border-radius: 10px;
  max-width: 90%;
}

.chat-user {
  background: var(--surface-2);
  align-self: flex-end;
  color: var(--text);
}

.chat-ai {
  background: var(--brand);
  color: #fff;
  align-self: flex-start;
}

.chat-error {
  background: #fde8e8;
  color: var(--danger);
  align-self: flex-start;
}

.ai-chat-input-row {
  display: flex;
  gap: 6px;
}

.ai-chat-input-row input {
  flex: 1;
  padding: 8px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-family: 'DM Sans', sans-serif;
  background: var(--surface);
}

.ai-chat-input-row button {
  padding: 8px 14px;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
}

.ai-chat-input-row button:disabled { opacity: 0.5; }

#ai-chat-loading {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Desktop overrides ────────────────────────── */

@media (min-width: 521px) {
  .modal {
    align-items: center;
  }
  .modal-content {
    border-radius: 16px;
    padding: 28px 28px 32px;
    width: 95%;
  }
  .modal-content::before { display: none; }
  main { padding: 0 16px 40px; }
  .toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .toolbar button { padding: 9px 14px; }
}

/* ── Toolbar primary buttons ──────────────────── */

.btn-tool-primary {
  background: var(--brand) !important;
  color: #fff !important;
  border-color: var(--brand) !important;
  font-weight: 600 !important;
}
.btn-tool-primary:hover {
  background: var(--brand-light) !important;
  border-color: var(--brand-light) !important;
}

/* ── Streak badge ─────────────────────────────── */

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 14px;
  box-shadow: var(--shadow);
}

/* ── Plan card variants ───────────────────────── */

.plan-card {
  border-left: 3px solid var(--accent);
}
.plan-card--done {
  border-left-color: var(--success);
  opacity: 0.75;
}
.plan-card--done h4 { color: var(--text-muted); }
.plan-date-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 0.02em;
}

/* ── Plan completion stats ────────────────────── */

.plan-stats {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  margin-bottom: 14px;
}

/* ── 1RM sparkline ────────────────────────────── */

.lift-card-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.lift-sparkline { display: block; }

/* ── PR banner ────────────────────────────────── */

.pr-banner {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  color: #fff;
  padding: 14px 20px;
  border-radius: 14px;
  box-shadow: 0 8px 32px rgba(31,18,9,0.35);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  z-index: 999;
  pointer-events: none;
  white-space: nowrap;
}
.pr-banner--show { opacity: 1; transform: translateX(-50%) translateY(0); }
.pr-banner-trophy { font-size: 1.4rem; line-height: 1; }
.pr-banner strong { display: block; font-size: 0.78rem; letter-spacing: 0.07em; text-transform: uppercase; opacity: 0.8; }
.pr-banner-detail { font-size: 1rem; font-weight: 700; font-family: 'Barlow Condensed', sans-serif; letter-spacing: 0.02em; }

/* ── Dark mode ────────────────────────────────── */

@media (prefers-color-scheme: dark) {
  :root {
    --bg:           #1c1108;
    --surface:      #271710;
    --surface-2:    #321f13;
    --brand:        #9b6a52;
    --brand-light:  #b07a60;
    --accent:       #d4762c;
    --accent-hover: #b86225;
    --text:         #f0e6de;
    --text-muted:   #a08070;
    --border:       #3d2618;
    --border-light: #4d3020;
    --shadow:        0 2px 8px rgba(0,0,0,0.3);
    --shadow-lg:     0 8px 28px rgba(0,0,0,0.5);
  }
  header { box-shadow: 0 2px 16px rgba(0,0,0,0.5); }
  .month-header { background: #3d2618; }
  .month-header:hover { background: #4d3020; }
  .session-card, .lift-card { background: var(--surface); }
  .modal-content { background: #1e1209; }
  .ac-list { background: var(--surface); }
  .group-header { background: #3d2618; }
  .btn-tool-primary { background: var(--brand) !important; }
}

/* Progression feature */
.prog-badge {
  display: inline-block;
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent, #e07b39);
  color: #fff;
  margin-left: 4px;
  vertical-align: middle;
  opacity: 0.85;
}

.weight-needed {
  color: #c07700;
  font-style: italic;
  font-size: 0.85em;
}

.prog-section {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.prog-toggle-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted, #888);
  cursor: pointer;
}

.prog-detail {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.prog-type-seg {
  display: flex;
  border-radius: 4px;
  overflow: hidden;
}

.prog-type-btn {
  padding: 2px 8px;
  font-size: 0.75rem;
  background: var(--surface-2, #2a2a2a);
  border: none;
  cursor: pointer;
  color: var(--text-muted, #888);
}

.prog-type-btn.active {
  background: var(--accent, #e07b39);
  color: #fff;
}

.week-picker-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 10px 0;
}

.week-picker-row button {
  padding: 4px 10px;
  font-size: 1.1rem;
}

.modal-hint {
  font-size: 0.9rem;
  color: var(--text-muted, #888);
  margin-bottom: 8px;
}
