/* === RESET & BASE === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* === SECTIONS === */
.app-section { display: none; }
.app-section.active { display: block; }

/* === MAIN NAVIGATION === */
.main-nav {
  background: transparent;
  border-bottom: none;
  position: sticky;
  top: 68px;
  z-index: 90;
  box-shadow: 0 1px 4px rgba(0,0,0,.05);
}

.nav-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-inner::-webkit-scrollbar { display: none; }

.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 14px 18px;
  font-size: .875rem;
  font-weight: 500;
  color: var(--slate-500);
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color var(--transition), border-color var(--transition);
}

.nav-tab svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-tab:hover { color: var(--teal); }

.nav-tab.active {
  color: var(--teal);
  border-bottom-color: var(--teal);
  font-weight: 600;
}

/* === SEARCH INPUT === */
.search-input {
  appearance: none;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: .9rem;
  color: var(--slate-700);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
  background: var(--slate-50);
  font-family: inherit;
}

.search-input:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26, 43, 74, 0.3);
  background: var(--white);
}

/* === BADGE VARIANTS === */
.badge-region { background: var(--teal-light); color: var(--teal-dark); }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-violet { background: #ede9fe; color: #6d28d9; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: var(--slate-100); color: var(--slate-500); }
.badge-muscle { background: #1A2B4A; color: #7AAAE8; border: 1px solid #2A3F6A; }

/* === SECTION CATEGORIES === */
.section-category { margin-bottom: 40px; }

.category-heading {
  font-size: 1rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--teal-light);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* === PROGRAMS === */
.programs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 18px;
}

.program-card {
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.program-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

.program-category-badge {
  font-size: 0.7rem;
  color: var(--primary);
  border: 1px solid var(--primary);
  padding: 0.15rem 0.5rem;
  border-radius: 3px;
  opacity: 0.7;
  white-space: nowrap;
  align-self: flex-start;
  margin-left: auto;
  flex-shrink: 0;
}

.program-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--slate-900);
  line-height: 1.3;
}

.program-freq {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: .78rem;
  color: var(--slate-500);
  margin-top: 2px;
}

.program-desc {
  font-size: .875rem;
  color: var(--slate-500);
  margin-bottom: 12px;
  line-height: 1.5;
}

.program-details {
  padding-left: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.program-details li { font-size: .84rem; color: var(--slate-700); line-height: 1.5; }

.program-prescription {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-100);
}

.prog-presc-item {
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  flex: 1;
  min-width: 100px;
}

.prog-presc-label {
  display: block;
  font-size: .65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate-400);
  margin-bottom: 2px;
}

.prog-presc-val { font-size: .82rem; color: var(--slate-700); font-weight: 500; }

.client-instruction-section {
  margin-top: 1.25rem;
  border-top: 1px solid var(--slate-200);
  padding-top: 1rem;
}

.client-instruction-heading {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--slate-500);
  margin-bottom: .75rem;
}

.instruction-text {
  white-space: pre-wrap;
  font-family: inherit;
  font-size: .85rem;
  line-height: 1.65;
  background: var(--slate-50);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: .875rem 1rem;
  margin-bottom: .75rem;
  color: var(--slate-700);
}

.copy-btn {
  background: var(--teal);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: .45rem 1rem;
  cursor: pointer;
  font-size: .82rem;
  font-weight: 500;
  transition: opacity .15s;
}
.copy-btn:hover { opacity: .85; }

/* === EDUCATION === */
.edu-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Section headings within education */
.edu-section-heading {
  margin: 0 0 16px;
}
.edu-section-heading h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 4px;
}
.edu-section-heading p {
  font-size: .84rem;
  color: var(--slate-500);
  margin: 0;
}
.edu-section-heading--clinical {
  margin-top: 36px;
}

/* Patient edu grid — full-width accordion list */
.edu-patient-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

/* Patient education accordion card */
.edu-pat-card {
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color .15s;
}
.edu-pat-card.open {
  border-color: var(--teal);
}

.edu-pat-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: none;
  border: none;
  cursor: pointer;
  text-align: left;
}
.edu-pat-toggle:hover { background: var(--bg-secondary); }

.edu-pat-chevron {
  font-size: .65rem;
  color: var(--slate-400);
  flex-shrink: 0;
  transition: transform .18s ease;
  display: inline-block;
  line-height: 1;
  user-select: none;
}
.edu-pat-chevron.open { transform: rotate(180deg); }

.edu-pat-toggle-left {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.edu-pat-icon { font-size: 1.6rem; flex-shrink: 0; }
.edu-pat-title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 4px;
}

/* Badge variant */
.badge-teal {
  background: var(--teal-light);
  color: var(--teal-dark);
  border: 1px solid var(--teal);
}

/* Patient edu card body */
.edu-pat-body {
  padding: 0 20px 20px;
  border-top: 1px solid var(--slate-200);
}

.edu-sec { margin-bottom: 16px; }
.edu-sec:last-child { margin-bottom: 0; }

.edu-sec-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 16px 0 8px;
}
.edu-sec-label svg { flex-shrink: 0; width: 14px; height: 14px; }

.edu-sec-label--default { color: var(--teal-dark); }
.edu-sec-label--green   { color: #15803d; }
.edu-sec-label--red     { color: #b91c1c; }
.edu-sec-label--amber   { color: #92400e; }

.edu-sec-text {
  font-size: .88rem;
  color: var(--slate-700);
  line-height: 1.65;
  margin: 0;
}

.edu-sec-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0;
}
.edu-sec-list li { font-size: .87rem; color: var(--slate-700); line-height: 1.55; }
.edu-sec-list--green li::marker { color: #15803d; }
.edu-sec-list--red   li::marker { color: #b91c1c; }
.edu-sec-list--amber li::marker { color: #92400e; }

.edu-source {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: .75rem;
  color: var(--slate-400);
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px dashed var(--slate-200);
  line-height: 1.5;
}
.edu-source svg { flex-shrink: 0; margin-top: 2px; }

/* Clinical reference grid */
.edu-clinical-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 16px;
}

.edu-card {
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.edu-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.edu-icon { font-size: 1.8rem; flex-shrink: 0; }
.edu-title { font-size: .95rem; font-weight: 700; color: var(--slate-900); margin-bottom: 4px; }

.edu-content-list {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.edu-content-list li { font-size: .85rem; color: var(--slate-700); line-height: 1.55; }

.edu-tip {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: .8rem;
  color: var(--teal-dark);
  background: var(--teal-light);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  line-height: 1.5;
}

.edu-tip svg { flex-shrink: 0; margin-top: 2px; }

.edu-card--clinical { grid-column: span 1; }

.edu-clinical-intro {
  font-size: .87rem;
  color: var(--slate-600);
  line-height: 1.6;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--slate-100);
}

.edu-clinical-subsection {
  margin-bottom: 14px;
}

.edu-clinical-subheading {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--teal-dark);
  margin-bottom: 6px;
}

.edu-clinical-note {
  font-size: .8rem;
  color: var(--slate-600);
  background: var(--slate-50);
  border-left: 3px solid var(--teal-dark);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 7px 10px;
  margin-top: 6px;
  line-height: 1.5;
}

/* === FORMS === */
.forms-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.form-card {
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.form-card-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.form-abbr {
  background: var(--primary);
  color: #4D7CC7;
  font-size: .72rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  flex-shrink: 0;
  white-space: nowrap;
}

.form-title { font-size: .9rem; font-weight: 600; color: var(--slate-900); line-height: 1.3; }
.form-desc { font-size: .84rem; color: var(--slate-500); margin-bottom: 10px; line-height: 1.5; }

.form-scoring, .form-use {
  font-size: .8rem;
  color: var(--slate-700);
  margin-bottom: 6px;
  line-height: 1.5;
}

.form-scoring-label, .form-use-label {
  font-weight: 600;
  color: var(--slate-500);
}

.form-file {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--slate-100);
  font-size: .75rem;
  color: var(--slate-400);
}

.form-file code { font-family: monospace; color: var(--teal-dark); }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--slate-100);
}

.form-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--teal);
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  padding: .4rem .875rem;
  font-size: .8rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: opacity .15s;
}
.form-download-btn:hover { opacity: .85; }

.form-download-btn--secondary {
  background: #475569;
}
.form-download-btn--secondary:hover { background: #334155; opacity: 1; }

/* === CLINICAL === */
.clinical-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 20px;
}

.clinical-card {
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.clinical-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.clinical-icon { font-size: 1.8rem; flex-shrink: 0; }
.clinical-title { font-size: .95rem; font-weight: 700; color: var(--slate-900); margin-bottom: 4px; }

.clinical-sections { display: flex; flex-direction: column; gap: 12px; }

.clinical-section {
  padding: 10px 12px;
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--teal);
}

.clinical-section-heading {
  font-size: .82rem;
  font-weight: 700;
  color: var(--teal-dark);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.clinical-section-content { font-size: .84rem; color: var(--slate-700); line-height: 1.6; }

:root {
  --primary: #1B2A45;
  --primary-dark: #111C30;
  --primary-light: #243A60;
  --primary-subtle: #EEF2F8;
  --primary-border: #9AADC8;

  --accent: #2563EB;
  --accent-hover: #1D4ED8;

  --bg: #0f172a;
  --bg-secondary: #1a2b42;
  --bg-tertiary: #243a5e;
  --card-bg: #1e293b;
  --card-bg-hover: #253347;

  --text-primary: #ffffff;
  --text-secondary: #ffffff;
  --text-muted: #ffffff;
  --text-inverse: #FFFFFF;

  --border: #334155;
  --border-strong: #475569;
  --border-focus: #60a5fa;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  --header-height: 60px;

  --font: 'Comic Neue', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Bangers', cursive;
  --font-body: 'Comic Neue', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  --transition: 150ms ease;

  /* Comic theme tokens — vaalea versio tummalle pohjalle */
  --comic-ink: #e2e8f0;
  --comic-border: 3px solid rgba(255,255,255,0.45);
  --comic-border-strong: 3.5px solid rgba(255,255,255,0.55);
  --comic-shadow: 4px 4px 0px rgba(255,255,255,0.12);
  --comic-shadow-lg: 6px 6px 0px rgba(255,255,255,0.12);
  --comic-shadow-hover: 6px 7px 0px rgba(255,255,255,0.18);
  --comic-shadow-active: 2px 2px 0px rgba(255,255,255,0.07);
  --comic-radius: 7px;
  --comic-transition: 150ms ease-out;

  /* Legacy aliases for backward compat */
  --teal: var(--primary);
  --teal-dark: var(--primary-dark);
  --teal-light: var(--primary-subtle);
  --teal-mid: var(--primary-border);
  --white: #ffffff;
  --slate-900: var(--text-primary);
  --slate-700: var(--text-secondary);
  --slate-600: var(--text-secondary);
  --slate-500: var(--text-muted);
  --slate-400: var(--text-muted);
  --slate-300: var(--border-strong);
  --slate-200: var(--border);
  --slate-100: var(--bg-tertiary);
  --slate-50: var(--bg-secondary);
  --shadow: var(--shadow-md);
  --radius: var(--radius-md);
  --amber: #d97706;
  --green: #15803d;
  --red: #b91c1c;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  letter-spacing: 0.04em;
}

.filter-group-label {
  font-family: var(--font-heading);
  letter-spacing: 0.06em;
}

.nav-tab {
  font-family: var(--font-heading);
  letter-spacing: 0.06em;
  font-size: .95rem;
}

.card-title {
  font-family: var(--font-heading);
  letter-spacing: 0.03em;
}

.view-title,
.view-header-title,
.modal-title,
.section-title {
  font-family: var(--font-heading);
  letter-spacing: 0.05em;
}

/* === HEADER === */
/* ============================================================
   HEADER & NAVIGAATIO (uusi rakenne)
   ============================================================ */

.top-header {
  background: #0a1525;
  border-bottom: 1px solid #1e293b;
  height: var(--header-height);
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: var(--shadow-sm);
}

.site-logo {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  margin-right: 1rem;
  flex-shrink: 0;
}

.logo-text {
  font-family: var(--font-heading);
  font-size: 1.5rem;
  font-weight: 400;
  color: #ffffff;
  letter-spacing: 0.06em;
}

.logo-sub {
  font-family: var(--font-body);
  font-size: 0.62rem;
  color: rgba(255,255,255,0.42);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.main-nav {
  display: flex;
  align-items: center;
  height: 100%;
  gap: 0;
  flex: 1;
}

.nav-item {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.nav-btn {
  background: none;
  border: none;
  color: #e2e8f0;
  font-family: var(--font-heading);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0 1.1rem;
  height: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border-bottom: 2px solid transparent;
  transition: all var(--transition);
  white-space: nowrap;
}

.nav-btn:hover,
.nav-item.open .nav-btn {
  color: #ffffff;
  background: rgba(255,255,255,0.1);
  border-bottom-color: rgba(255,255,255,0.5);
}

.nav-chevron {
  width: 10px;
  height: 6px;
  transition: transform var(--transition);
}

.nav-item.open .nav-chevron { transform: rotate(180deg); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  padding: 0.5rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: all 180ms ease;
  z-index: 300;
}

.nav-item.open .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
  text-decoration: none;
  color: var(--text-primary);
}

.dropdown-item:hover { background: var(--bg-secondary); }
.dropdown-item.active { background: var(--primary-subtle); }

.dropdown-icon {
  width: 32px;
  height: 32px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
}

.dropdown-icon svg { width: 16px; height: 16px; }

.dropdown-item.active .dropdown-icon {
  background: var(--primary);
  color: var(--text-inverse);
}

.dropdown-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}

.dropdown-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.create-btn {
  background: #ffffff;
  color: #0f172a;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: auto;
  transition: background var(--transition);
  white-space: nowrap;
  flex-shrink: 0;
}

.create-btn:hover { background: #e2e8f0; }

/* ============================================================
   NÄKYMÄT
   ============================================================ */

.main-content {
  min-height: calc(100vh - var(--header-height));
  background: var(--bg);
}

.view { display: none; }
.view.active-view { display: block; }

.view-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 1.5rem 0;
  position: sticky;
  top: var(--header-height);
  z-index: 100;
}

.view-header-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.view-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
}

.view-desc {
  font-size: 0.825rem;
  color: var(--text-muted);
}

.view-body {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem;
}

.filters-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-bottom: 0.75rem;
  max-width: 1440px;
  margin: 0 auto;
}

.filter-input,
.filter-select {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.75rem;
  font-family: var(--font);
  font-size: 0.825rem;
  color: var(--text-primary);
  transition: border-color var(--transition);
  min-width: 0;
}

.filter-input { flex: 1; min-width: 160px; }
.filter-select { flex-shrink: 0; }

.filter-input:focus,
.filter-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.btn-clear {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.45rem 0.875rem;
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.btn-clear:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
}

.btn-clear-sel {
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: var(--radius-md);
  padding: 0.4rem 0.875rem;
  font-family: var(--font);
  font-size: 0.8rem;
  color: var(--text-inverse);
  cursor: pointer;
  transition: background var(--transition);
}

.btn-clear-sel:hover { background: rgba(255,255,255,0.25); }

.btn-create {
  background: var(--accent);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.5rem 1.1rem;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-create:hover { background: var(--accent-hover); }

.selection-count {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-inverse);
}

/* ============================================================
   LIITTEET
   ============================================================ */

.liitteet-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.liite-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  transition: border-color var(--transition);
}

.liite-card:hover { border-color: var(--primary-border); }

.liite-abbr {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent);
  min-width: 60px;
  text-align: center;
  background: var(--primary-subtle);
  padding: 0.3rem 0.5rem;
  border-radius: var(--radius-sm);
}

.liite-info { flex: 1; }
.liite-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.liite-desc { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.1rem; }

.liite-btn {
  background: var(--primary);
  color: var(--text-inverse);
  padding: 0.35rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition);
  white-space: nowrap;
}

.liite-btn:hover { background: var(--primary-dark); }

/* ============================================================
   YHTEYDENOTTO
   ============================================================ */

.contact-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.contact-field { display: flex; flex-direction: column; gap: 0.4rem; }

.contact-field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.contact-input,
.contact-textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text-primary);
  transition: border-color var(--transition);
}

.contact-input:focus,
.contact-textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.contact-textarea { resize: vertical; }

.btn-submit {
  background: var(--accent);
  color: var(--text-inverse);
  border: none;
  border-radius: var(--radius-md);
  padding: 0.625rem 1.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  align-self: flex-start;
  transition: background var(--transition);
}

.btn-submit:hover { background: var(--accent-hover); }

.placeholder-card {
  background: var(--card-bg);
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.external-link-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.btn-primary-link {
  background: var(--primary);
  color: var(--text-inverse);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition);
}

.btn-primary-link:hover { background: var(--primary-dark); }

/* ============================================================
   VANHA HEADER (legacy — säilytetään muita elementtejä varten)
   ============================================================ */

header {
  background: var(--teal);
  color: var(--white);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 38px;
  height: 38px;
  background: rgba(255,255,255,.15);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-icon svg { width: 22px; height: 22px; fill: white; }

.logo-text h1 {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.2;
}

.logo-text p {
  font-size: .72rem;
  opacity: .75;
  font-weight: 400;
  letter-spacing: .03em;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* === MAIN LAYOUT === */
.app {
  max-width: 1280px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* === PAGE TITLE === */
.page-title {
  margin-bottom: 28px;
}

.page-title h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: -.02em;
}

.page-title p {
  color: var(--slate-500);
  margin-top: 4px;
  font-size: .95rem;
}

/* === FILTERS === */
.filters {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--slate-200);
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 180px;
}

.filter-group label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--slate-500);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.filter-group select {
  appearance: none;
  background: var(--slate-50) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-sm);
  padding: 9px 34px 9px 12px;
  font-size: .9rem;
  color: var(--slate-700);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

.filter-group select:focus {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26, 43, 74, 0.3);
}

.filter-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  margin-left: auto;
}

/* === CHIP FILTER SYSTEM === */
.filters-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.filters-bar--simple {
  padding: 0.625rem 0;
  border-top: 1px solid var(--border);
  border-bottom: none;
  margin-top: 0.5rem;
  background: none;
  position: static;
}

.filters-bar--simple .search-wrap {
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
}

.search-wrap .filter-search {
  padding-left: 32px;
}

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

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 340px;
}

.filter-search {
  width: 100%;
  padding: 8px 36px 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .9rem;
  background: #fff;
  color: var(--text);
  transition: border-color var(--transition);
}

.filter-search:focus {
  outline: none;
  border-color: var(--primary);
}

.btn-clear-search {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  padding: 2px;
  display: none;
}

.btn-clear-search.visible { display: block; }

.btn-clear-filters {
  padding: 7px 14px;
  font-size: .82rem;
  font-weight: 600;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}

.btn-clear-filters:hover {
  background: rgba(27,42,69,0.07);
  color: var(--primary);
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.filter-group-label {
  font-size: .72rem;
  font-weight: 700;
  color: #e2e8f0;
  text-transform: uppercase;
  letter-spacing: .07em;
}

.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #fff;
  font-size: .82rem;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  user-select: none;
}

.chip:hover {
  background: rgba(27,42,69,0.07);
  border-color: var(--primary);
}

.chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* ---- Drill-down navigaatio — comic style ---- */
@keyframes drillSlideIn {
  from {
    opacity: 0;
    transform: translateX(-18px) translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

.drill-nav {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drill-row {
  display: flex;
}

/* Kaikki-nappi (taso 0) */
.drill-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 7px;
  border: 3px solid #0f172a;
  background: #0f172a;
  color: #fff;
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .02em;
  cursor: pointer;
  box-shadow: 3px 3px 0px #0f172a;
  transition: transform 150ms ease, box-shadow 150ms ease;
  user-select: none;
}
.drill-all-btn:hover {
  transform: translateY(-3px);
  box-shadow: 5px 6px 0px #0f172a;
}
.drill-all-btn:active {
  transform: translateY(0);
  box-shadow: 1px 1px 0px #0f172a;
}

/* Breadcrumb-rivi */
.drill-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

/* Takaisin-nappi */
.drill-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 11px;
  border-radius: 7px;
  border: 2.5px solid #0f172a;
  background: transparent;
  color: #0f172a;
  font-size: .78rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 0px #0f172a;
  transition: transform 150ms ease, box-shadow 150ms ease, background 100ms;
  user-select: none;
}
.drill-back-btn:hover {
  transform: translateY(-2px);
  box-shadow: 4px 4px 0px #0f172a;
  background: rgba(15,23,42,0.05);
}
.drill-back-btn:active {
  transform: translateY(0);
  box-shadow: 1px 1px 0px #0f172a;
}

.drill-sep {
  color: #0f172a;
  font-size: .9rem;
  font-weight: 700;
  line-height: 1;
}

/* Aktiivinen alue breadcrumbissa */
.drill-region-crumb {
  padding: 4px 11px;
  border-radius: 7px;
  border: 2.5px solid #0f172a;
  background: transparent;
  color: #0f172a;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 2px 2px 0px #0f172a;
  transition: transform 150ms ease, box-shadow 150ms ease, background 100ms, color 100ms;
  user-select: none;
}
.drill-region-crumb:hover {
  transform: translateY(-2px);
  box-shadow: 4px 4px 0px #0f172a;
}
.drill-region-crumb.current {
  background: #0f172a;
  color: #fff;
  box-shadow: 3px 3px 0px rgba(0,0,0,0.35);
}

/* Chipirivi — animoitu sisääntulo */
.drill-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  animation: drillSlideIn 200ms cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Yksittäinen chip */
.drill-chip {
  padding: 5px 13px;
  border-radius: 7px;
  border: 3px solid #0f172a;
  background: #fff;
  font-size: .82rem;
  font-weight: 700;
  color: #0f172a;
  cursor: pointer;
  box-shadow: 3px 3px 0px #0f172a;
  transition: transform 150ms ease, box-shadow 150ms ease, background 100ms, color 100ms;
  user-select: none;
}
.drill-chip:hover {
  transform: translateY(-3px);
  box-shadow: 5px 6px 0px #0f172a;
  background: rgba(15,23,42,0.05);
}
.drill-chip:active {
  transform: translateY(0);
  box-shadow: 1px 1px 0px #0f172a;
}
.drill-chip.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
  box-shadow: 4px 4px 0px rgba(0,0,0,0.4);
}
.drill-chip.active:hover {
  transform: translateY(-3px);
  box-shadow: 6px 7px 0px rgba(0,0,0,0.4);
}

/* ---- Pomppu-monivalinta (vaikeus, välineistö) ---- */
.pomppu-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.pomppu-chip {
  padding: 5px 13px;
  border-radius: 7px;
  border: 3px solid #0f172a;
  background: #fff;
  font-size: .82rem;
  font-weight: 700;
  font-family: var(--font-body);
  color: #0f172a;
  cursor: pointer;
  box-shadow: 3px 3px 0px #0f172a;
  transition: transform 150ms ease-out, box-shadow 150ms ease-out, background 100ms;
  user-select: none;
}
.pomppu-chip:hover {
  transform: translateY(-3px);
  box-shadow: 5px 6px 0px #0f172a;
  background: rgba(15,23,42,0.05);
}
.pomppu-chip:active {
  transform: translateY(2px);
  box-shadow: 1px 1px 0px #0f172a;
}
.pomppu-chip.active {
  background: #0f172a;
  border-color: #0f172a;
  color: #fff;
  box-shadow: 4px 4px 0px rgba(0,0,0,0.4);
}
.pomppu-chip.active:hover {
  transform: translateY(-3px);
  box-shadow: 6px 7px 0px rgba(0,0,0,0.4);
}

.active-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.active-filters-label {
  font-size: .78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.active-filters-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.active-chip {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(27,42,69,0.1);
  border: 1px solid rgba(27,42,69,0.2);
  font-size: .8rem;
  color: var(--primary);
  cursor: pointer;
  transition: background var(--transition);
}

.active-chip:hover { background: rgba(27,42,69,0.18); }

.active-chip .chip-x {
  font-size: .9rem;
  line-height: 1;
  margin-left: 2px;
  opacity: .7;
}

/* === RESULTS COUNT === */
.results-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.results-count {
  font-size: .88rem;
  color: #ffffff;
}

.results-count span { color: #ffffff; font-weight: 600; }

/* === EXERCISE GRID === */
.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 18px;
}

/* === EXERCISE CARD === */
.exercise-card {
  background: var(--white);
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
  position: relative;
  user-select: none;
}

.exercise-card:hover {
  border-color: var(--teal);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.exercise-card.selected {
  border-color: var(--primary);
  background: var(--primary-subtle);
  box-shadow: 0 0 0 3px rgba(26, 43, 74, 0.4), var(--shadow);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.card-checkbox {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 2px solid var(--slate-300);
  flex-shrink: 0;
  margin-top: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  background: var(--white);
}

.exercise-card.selected .card-checkbox {
  background: var(--teal);
  border-color: var(--teal);
}

.card-checkbox svg {
  width: 11px;
  height: 11px;
  stroke: white;
  stroke-width: 2.5;
  fill: none;
  opacity: 0;
  transition: opacity var(--transition);
}

.exercise-card.selected .card-checkbox svg { opacity: 1; }

.card-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: var(--slate-900);
  line-height: 1.3;
}

.card-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: capitalize;
}

.badge-body {
  background: var(--teal-light);
  color: var(--teal-dark);
}

.badge-easy { background: #dcfce7; color: var(--green); }
.badge-medium { background: #fef3c7; color: var(--amber); }
.badge-hard { background: #fee2e2; color: var(--red); }

.card-description {
  font-size: .875rem;
  color: var(--slate-500);
  line-height: 1.55;
  margin-bottom: 14px;
}

.card-meta {
  display: flex;
  gap: 16px;
  font-size: .78rem;
  color: var(--slate-500);
  border-top: 1px solid var(--slate-100);
  padding-top: 12px;
}

.card-meta-item { display: flex; align-items: center; gap: 4px; }
.card-meta-item svg { width: 12px; height: 12px; flex-shrink: 0; }

/* Sets / reps prescription line */
.card-prescription {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  margin: .25rem 0 .15rem;
}
.card-prescription span {
  font-size: .72rem;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  border-radius: 4px;
  padding: 2px 7px;
  border: 1px solid var(--border);
}

/* Expand instructions */
.card-expand-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: .78rem;
  color: var(--teal);
  font-weight: 500;
  padding: 6px 0 0;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition);
  text-decoration: none;
}

.card-expand-btn:hover { color: var(--teal-dark); }

.card-expand-btn svg {
  width: 12px;
  height: 12px;
  transition: transform var(--transition);
}

.card-expand-btn.open svg { transform: rotate(180deg); }

.card-instructions {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--slate-100);
}

.card-instructions.visible { display: block; }

.card-instructions ol {
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.card-instructions li {
  font-size: .84rem;
  color: var(--slate-600, #475569);
  line-height: 1.5;
}

/* ============================================================
   HARJOITEKORTIN KUVANAPPI
   ============================================================ */
.card-image-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  padding: 0.5rem 0 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color var(--transition);
  width: 100%;
  text-align: left;
  margin-top: 0.25rem;
  border-top: 1px dashed var(--border);
}

.card-image-btn:hover { color: var(--primary); }
.card-image-btn.open { color: var(--primary); }

.card-image-btn--empty {
  opacity: 0.4;
  cursor: default;
}

.card-image-btn--empty:hover { color: var(--text-muted); }

.card-image-panel {
  display: none;
  margin-top: 0.5rem;
}

.card-image-panel.visible { display: block; }

.card-image-inner {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-image-wrap {
  flex: 1;
  min-width: 120px;
}

.card-image-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.card-image {
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  object-fit: cover;
  max-height: 200px;
  background: var(--bg);
}

@media print {
  .card-image-panel { display: block !important; }
  .card-image { max-height: 150px; }
}

/* === EMPTY STATE === */
.empty-state {
  grid-column: 1/-1;
  text-align: center;
  padding: 64px 24px;
  color: #ffffff;
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  display: block;
  opacity: .4;
}

.empty-state p { font-size: 1rem; }

/* === SELECTION PANEL === */
.selection-panel {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1A2B4A;
  color: var(--text-inverse);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.5);
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  z-index: 200;
}

.selection-panel.visible { transform: translateY(0); }

.selection-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.selection-badge {
  background: rgba(255,255,255,.2);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .95rem;
}

.selection-text { font-size: .9rem; opacity: .9; }
.selection-text strong { font-weight: 600; opacity: 1; }

.selection-actions { display: flex; gap: 10px; }

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--teal);
  color: var(--white);
}

.btn-primary:hover { background: var(--teal-dark); }

.btn-ghost {
  background: transparent;
  color: var(--white);
  border: 1.5px solid rgba(255,255,255,.35);
}

.btn-ghost:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.6); }

.btn-outline {
  background: transparent;
  color: var(--slate-600, #475569);
  border: 1.5px solid var(--slate-200);
}

.btn-outline:hover { border-color: var(--slate-400); color: var(--slate-900); }

.btn-white {
  background: var(--white);
  color: var(--teal-dark);
}

.btn-white:hover { background: var(--teal-light); }

.btn-sm { padding: 6px 12px; font-size: .8rem; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.open {
  display: flex;
}

.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  background: var(--primary);
  color: var(--text-inverse);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.modal-title {
  font-size: 0.925rem;
  font-weight: 600;
  color: var(--text-inverse);
}

.modal-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.modal-close:hover { background: rgba(255,255,255,0.25); }

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

/* Step-elementit */
.step-info {
  font-size: 0.825rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  margin-bottom: 1rem;
}

.step-list {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 45vh;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.step-ex-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

.step-ex-item:last-child { border-bottom: none; }

.step-num {
  width: 22px;
  height: 22px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.step-ex-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.step-ex-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.step-category-label {
  padding: 0.4rem 0.875rem;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  background: var(--primary-subtle);
  border-bottom: 1px solid var(--border);
}

.step-program-item {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.step-program-item:hover { background: var(--bg-secondary); }
.step-program-item.selected {
  background: var(--primary-subtle);
  border-left: 3px solid var(--primary);
}

.step-program-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.step-program-freq {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.step-program-presc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-top: 0.4rem;
}

.presc-tag {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.15rem 0.5rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.step-edu-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.875rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}

.step-edu-item:hover { background: var(--bg-secondary); }
.step-edu-item.selected { background: var(--primary-subtle); }

.step-edu-check {
  width: 20px;
  height: 20px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--primary);
  transition: all var(--transition);
}

.step-edu-item.selected .step-edu-check {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.step-edu-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.step-edu-cat {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.step-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.btn-modal-cancel {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-modal-cancel:hover { border-color: var(--border-strong); color: var(--text-secondary); }

.btn-modal-back {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-modal-back:hover { background: var(--bg-tertiary); }

.btn-modal-loop {
  background: var(--bg);
  border: 1.5px solid var(--primary);
  color: var(--primary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.btn-modal-loop:hover { background: var(--primary-subtle); }

.btn-modal-next {
  background: var(--primary);
  border: none;
  color: white;
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition);
}

.btn-modal-next:hover { background: var(--primary-dark); }

/* ============================================================
   KETJUPALKKI
   ============================================================ */
.chain-bar {
  background: var(--primary-subtle);
  border-bottom: 1px solid var(--primary-border);
  padding: 0.625rem 1.5rem;
}

.chain-bar-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.chain-bar-chains {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chain-tag {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--primary);
  color: white;
  padding: 0.25rem 0.5rem 0.25rem 0.4rem;
  border-radius: 999px;
  font-size: 0.775rem;
}

.chain-tag-num {
  background: rgba(255,255,255,0.2);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chain-tag-info { font-weight: 500; }

.chain-tag-remove {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background var(--transition);
}

.chain-tag-remove:hover { background: rgba(255,255,255,0.3); }

.chain-bar-actions {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-shrink: 0;
}

.chain-bar-preview {
  background: var(--primary);
  color: white;
  border: none;
  padding: 0.4rem 0.875rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition);
}

.chain-bar-preview:hover { background: var(--primary-dark); }

.chain-bar-clear {
  background: none;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.775rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.chain-bar-clear:hover { border-color: #ef4444; color: #ef4444; }

/* ============================================================
   ESIKATSELU
   ============================================================ */
.preview-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.875rem;
  margin-bottom: 1rem;
}

.preview-scroll {
  max-height: 50vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1rem;
}

.preview-chain { margin-bottom: 1.5rem; }

.preview-chain-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.preview-chain-title {
  font-size: 0.875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--primary);
}

.preview-chain-title[contenteditable="true"]:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  font-style: italic;
}

.preview-chain-title[contenteditable="true"] {
  cursor: text;
  border-radius: var(--radius-sm);
  padding: 0.1rem 0.3rem;
  min-width: 80px;
}

.preview-chain-title[contenteditable="true"]:hover {
  outline: 1px dashed var(--primary-border);
}

.preview-chain-title[contenteditable="true"]:focus {
  outline: 2px solid var(--accent);
  background: var(--primary-subtle);
}

.preview-chain-remove {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
}

.preview-chain-remove:hover { border-color: #ef4444; color: #ef4444; }

.preview-divider {
  border: none;
  border-top: 2px dashed var(--border);
  margin: 1.5rem 0;
}

.preview-section { margin-bottom: 1rem; }

.preview-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  border-bottom: 1px solid var(--primary-border);
  padding-bottom: 0.3rem;
  margin-bottom: 0.75rem;
}

.preview-ex {
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.preview-ex:last-child { border-bottom: none; }

.preview-ex-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.3rem;
  flex-wrap: wrap;
}

.preview-ex-num {
  width: 20px;
  height: 20px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  font-size: 0.68rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.preview-ex-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  border-radius: 2px;
}

.preview-ex-badges { display: flex; gap: 0.3rem; margin-left: auto; }

.preview-badge {
  font-size: 0.65rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.45rem;
  color: var(--text-muted);
}

.preview-ex-steps {
  margin: 0.3rem 0 0.3rem 1.75rem;
  font-size: 0.8rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.preview-ex-steps li { outline: none; border-radius: 2px; }

.preview-ex-presc { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.3rem; }

.preview-program {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
}

.preview-program-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.2rem;
  outline: none;
}

.preview-program-freq {
  font-size: 0.775rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  outline: none;
}

.preview-program-presc { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }

.presc-box {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
}

.presc-box-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.1rem;
}

.presc-box-val { font-weight: 600; color: var(--text-primary); outline: none; }

.preview-instruction {
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: pre-wrap;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  outline: none;
}

.preview-edu {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.5rem;
}

.preview-edu-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
  outline: none;
}

.preview-edu-text { font-size: 0.8rem; line-height: 1.55; color: var(--text-secondary); outline: none; }

.preview-edu-group { margin-top: 0.5rem; }

.preview-edu-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.preview-edu ul {
  padding-left: 1.2rem;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.preview-edu li { outline: none; }

[contenteditable]:hover {
  outline: 1px dashed var(--primary-border);
  border-radius: 2px;
}

[contenteditable]:focus {
  outline: 2px solid var(--accent);
  background: var(--primary-subtle);
  border-radius: 2px;
}

.preview-nav { justify-content: space-between; }

/* ============================================================
   TOAST
   ============================================================ */
/* ============================================================
   LIITTEIDEN VALINTA ESIKATSELUSSA
   ============================================================ */
.diary-selector {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.875rem;
  margin-bottom: 1rem;
  background: var(--bg);
}

.diary-selector-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.diary-selector-chips {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.diary-chip {
  background: #fff;
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 0.4rem 0.875rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.diary-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(27,42,69,0.06);
}

.diary-chip.selected {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Kansisivu-toggle */
.cover-toggle-row {
  margin: 0.75rem 0 0.25rem;
}
.cover-toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}
.cover-toggle-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Kansisivu */
.cover-page {
  background: #0f172a;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  padding: 3rem 2rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
  text-align: center;
}
.cover-page-main {
  font-size: 1.75rem;
  font-weight: 300;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #e2e8f0;
}
.cover-page-sub {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: #94a3b8;
  margin-top: 0.5rem;
}
.cover-page-line {
  width: 48px;
  height: 1px;
  background: #334155;
  margin: 1.25rem auto;
}

/* Sivunvaihto tulostuksessa */
.print-page-break {
  page-break-before: always;
  break-before: page;
}

.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--primary);
  color: white;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all 250ms ease;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ============================================================
   ANATOMIA IFRAME
   ============================================================ */
.anatomy-iframe {
  width: 100%;
  height: calc(100vh - var(--header-height) - 80px);
  border: none;
  border-radius: var(--radius-md);
  background: var(--bg);
}

/* ============================================================
   VALMIIT PAKETIT
   ============================================================ */
.paketit-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1rem;
}

.paketti-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.paketti-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.paketti-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.paketti-title {
  font-size: 0.975rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.3;
}

.paketti-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.3rem;
  flex-shrink: 0;
}

.paketti-duration {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.paketti-desc {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

.paketti-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.paketti-tag {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.paketti-sisalto {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--bg);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.75rem;
}

.paketti-sisalto-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text);
}

.paketti-sisalto-item svg { color: var(--primary); flex-shrink: 0; }

.paketti-notes {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.775rem;
  color: var(--text);
  background: rgba(27,42,69,0.04);
  border: 1px solid rgba(27,42,69,0.12);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  line-height: 1.5;
}

.paketti-notes svg { color: var(--primary); flex-shrink: 0; margin-top: 1px; }

.paketti-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.25rem;
}

.btn-paketti-use {
  flex: 1;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  font-size: 0.825rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--transition);
}

.btn-paketti-use:hover { background: var(--primary-dark, #152238); }

.btn-paketti-empty {
  flex: 1;
  background: var(--bg);
  color: var(--text-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 1rem;
  font-size: 0.825rem;
  font-family: inherit;
  cursor: default;
}

.btn-paketti-edit {
  background: none;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.875rem;
  font-size: 0.825rem;
  font-family: inherit;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-paketti-edit:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ============================================================
   HARJOITTELUPAINOLASKURI
   ============================================================ */
.laskuri-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.laskuri-modal {
  background: #fff;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.laskuri-header {
  background: var(--primary);
  color: white;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.laskuri-title {
  font-size: 0.95rem;
  font-weight: 600;
}

.laskuri-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}

.laskuri-close:hover { background: rgba(255,255,255,0.25); }

.laskuri-body {
  padding: 1.25rem;
  overflow-y: auto;
  flex: 1;
}

.laskuri-input-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.laskuri-input-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.laskuri-input-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.laskuri-input-group input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--transition);
}

.laskuri-input-group input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27,42,69,0.1);
}

.laskuri-result {
  background: rgba(27,42,69,0.05);
  border: 1px solid rgba(27,42,69,0.15);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  margin-bottom: 1rem;
}

.laskuri-1rm {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--primary);
}

.laskuri-kaava {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.laskuri-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 0.875rem;
}

.laskuri-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.825rem;
}

.laskuri-table th {
  background: var(--primary);
  color: white;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}

.laskuri-table td {
  padding: 0.45rem 0.75rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

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

.laskuri-table tr:nth-child(even) td { background: var(--bg); }

.laskuri-row-active td {
  background: rgba(27,42,69,0.07) !important;
  color: var(--primary) !important;
  font-weight: 600;
}

.laskuri-placeholder {
  text-align: center;
  color: var(--text-muted);
  font-style: italic;
  padding: 1.5rem !important;
}

.laskuri-note {
  font-size: 0.775rem;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.btn-laskuri-preview {
  background: var(--primary);
  border: 1px solid var(--primary);
  color: white;
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.775rem;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-left: 0.75rem;
  transition: all var(--transition);
  vertical-align: middle;
}

.btn-laskuri-preview:hover {
  background: rgba(255,255,255,0.25);
  color: white;
}

/* ============================================================
   OTSIKKOVÄRIT
   ============================================================ */
.view-title { color: var(--primary); }
.category-heading { color: var(--primary); }
h1, h2, h3 { color: var(--primary); }

/* ============================================================
   COMIC THEME — globaalit overridet
   ============================================================ */

/* --- Harjoitekortit --- */
.exercise-card {
  border: var(--comic-border) !important;
  box-shadow: var(--comic-shadow) !important;
  border-radius: var(--comic-radius) !important;
  transition: transform var(--comic-transition), box-shadow var(--comic-transition), border-color var(--comic-transition) !important;
}
.exercise-card:hover {
  transform: translateY(-3px) !important;
  box-shadow: var(--comic-shadow-hover) !important;
  border-color: var(--comic-ink) !important;
}
.exercise-card.selected {
  background: var(--primary-subtle) !important;
  border-color: var(--comic-ink) !important;
  box-shadow: 4px 4px 0px var(--primary) !important;
}
.exercise-card:active {
  transform: translateY(2px) !important;
  box-shadow: var(--comic-shadow-active) !important;
}
.card-checkbox {
  border: 2.5px solid var(--comic-ink) !important;
  border-radius: 4px !important;
}

/* --- Modaali --- */
.modal {
  border: var(--comic-border-strong) !important;
  border-radius: var(--comic-radius) !important;
  box-shadow: var(--comic-shadow-lg) !important;
}
.modal-header {
  border-radius: calc(var(--comic-radius) - 1px) calc(var(--comic-radius) - 1px) 0 0 !important;
}

/* --- Modaalin napit --- */
.btn-modal-cancel,
.btn-modal-back,
.btn-modal-loop,
.btn-modal-next {
  border: var(--comic-border) !important;
  border-radius: var(--comic-radius) !important;
  font-weight: 700 !important;
  box-shadow: var(--comic-shadow) !important;
  transition: transform var(--comic-transition), box-shadow var(--comic-transition) !important;
}
.btn-modal-cancel:hover,
.btn-modal-back:hover,
.btn-modal-loop:hover,
.btn-modal-next:hover {
  transform: translateY(-3px) !important;
  box-shadow: var(--comic-shadow-hover) !important;
}
.btn-modal-cancel:active,
.btn-modal-back:active,
.btn-modal-loop:active,
.btn-modal-next:active {
  transform: translateY(2px) !important;
  box-shadow: var(--comic-shadow-active) !important;
}
.btn-modal-next { border-color: var(--comic-ink) !important; }

/* --- Suodattimet --- */
.filter-search {
  background: #0f172a !important;
  color: #ffffff !important;
  border: 3px solid #ffffff !important;
  border-radius: var(--comic-radius) !important;
  box-shadow: 4px 4px 0px #ffffff !important;
  transition: box-shadow var(--comic-transition) !important;
}
.filter-search:focus {
  outline: none !important;
  box-shadow: 6px 6px 0px #ffffff !important;
}
.btn-clear-filters {
  background: #0f172a !important;
  color: #ffffff !important;
  border: 3px solid #ffffff !important;
  border-radius: var(--comic-radius) !important;
  font-weight: 700 !important;
  box-shadow: 4px 4px 0px rgba(255,255,255,0.3) !important;
  transition: transform var(--comic-transition), box-shadow var(--comic-transition) !important;
}
.btn-clear-filters:hover {
  transform: translateY(-2px) !important;
  box-shadow: 6px 7px 0px rgba(255,255,255,0.35) !important;
  background: #1e293b !important;
  color: #ffffff !important;
}

/* --- Chip-suodattimet (muoto/vaikeus/välineistö) --- */
.chip {
  border: 2.5px solid var(--comic-ink) !important;
  border-radius: var(--comic-radius) !important;
  font-weight: 700 !important;
  box-shadow: 2px 2px 0px var(--comic-ink) !important;
  transition: transform var(--comic-transition), box-shadow var(--comic-transition), background var(--comic-transition) !important;
}
.chip:hover {
  transform: translateY(-2px) !important;
  box-shadow: 4px 4px 0px var(--comic-ink) !important;
  background: rgba(15,23,42,0.05) !important;
}
.chip.active {
  background: var(--comic-ink) !important;
  border-color: var(--comic-ink) !important;
  color: #fff !important;
  box-shadow: 3px 3px 0px rgba(0,0,0,0.35) !important;
}

/* --- Ketjupalkki-napit --- */
.chain-bar-preview,
.chain-bar-clear,
.chain-tag-remove {
  border: var(--comic-border) !important;
  border-radius: var(--comic-radius) !important;
  font-weight: 700 !important;
  box-shadow: var(--comic-shadow) !important;
  transition: transform var(--comic-transition), box-shadow var(--comic-transition) !important;
}
.chain-bar-preview:hover,
.chain-bar-clear:hover {
  transform: translateY(-2px) !important;
  box-shadow: var(--comic-shadow-hover) !important;
}

/* --- Valintapaneelin napit --- */
.btn-clear-sel,
.btn-create {
  border: var(--comic-border-strong) !important;
  border-radius: var(--comic-radius) !important;
  font-weight: 700 !important;
  box-shadow: var(--comic-shadow) !important;
  transition: transform var(--comic-transition), box-shadow var(--comic-transition) !important;
}
.btn-clear-sel:hover,
.btn-create:hover {
  transform: translateY(-2px) !important;
  box-shadow: var(--comic-shadow-hover) !important;
}

/* --- Yleiset .btn-elementit --- */
.btn {
  border: var(--comic-border) !important;
  border-radius: var(--comic-radius) !important;
  font-weight: 700 !important;
  box-shadow: var(--comic-shadow) !important;
  transition: transform var(--comic-transition), box-shadow var(--comic-transition) !important;
}
.btn:hover {
  transform: translateY(-2px) !important;
  box-shadow: var(--comic-shadow-hover) !important;
}
.btn:active {
  transform: translateY(2px) !important;
  box-shadow: var(--comic-shadow-active) !important;
}
.btn-ghost {
  border-color: rgba(255,255,255,0.7) !important;
  box-shadow: 3px 3px 0px rgba(255,255,255,0.25) !important;
}

/* --- Input/select/textarea yleiset --- */
input:not([type="checkbox"]):not([type="radio"]):not(.filter-search),
select,
textarea {
  border: var(--comic-border) !important;
  border-radius: var(--comic-radius) !important;
  transition: box-shadow var(--comic-transition) !important;
}
input:not([type="checkbox"]):not([type="radio"]):not(.filter-search):focus,
select:focus,
textarea:focus {
  outline: none !important;
  box-shadow: var(--comic-shadow) !important;
  border-color: var(--comic-ink) !important;
}

/* ============================================================
   TULOSTUS
   ============================================================ */
#printDocument { display: none; }

@page {
  margin: 1.5cm;
}

@media print {
  body > *:not(#printDocument) { display: none !important; }
  #printDocument { display: block !important; }

  .cover-page {
    background: #0f172a !important;
    color: #fff !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    min-height: 100vh;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    page-break-after: always;
    break-after: page;
    margin: 0;
    padding: 40mm 30mm;
    border-radius: 0;
  }
  .cover-page-main {
    font-size: 28pt;
    font-weight: 300;
    letter-spacing: 0.2em;
    color: #e2e8f0 !important;
  }
  .cover-page-sub {
    font-size: 11pt;
    letter-spacing: 0.45em;
    color: #94a3b8 !important;
  }
  .cover-page-line {
    background: #334155 !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    width: 60px;
    height: 1px;
  }

  .print-root {
    font-family: Arial, sans-serif;
    font-size: 10.5pt;
    color: #111;
    padding: 10mm;
  }

  .preview-chain-title {
    font-size: 10pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #1B2A45;
    border-bottom: 2px solid #1B2A45;
    padding-bottom: 3px;
    margin-bottom: 10px;
  }

  .preview-chain-remove,
  .preview-chain-header button { display: none !important; }

  .preview-divider {
    border-top: 1px dashed #ccc;
    margin: 12px 0;
  }

  .preview-section-label {
    font-size: 8pt;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #1B2A45;
    border-bottom: 1px solid #1B2A45;
    padding-bottom: 2px;
    margin-bottom: 8px;
  }

  .preview-ex { page-break-inside: avoid; }

  .preview-ex-num {
    background: #1B2A45;
    color: white;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .preview-ex-name { font-weight: 700; }
  .preview-ex-steps { font-size: 9.5pt; line-height: 1.5; }

  .preview-program {
    background: #f5f5f5 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border: 1px solid #ddd;
  }

  .preview-edu {
    background: #f8f8f8 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    border: 1px solid #ddd;
  }

  .preview-badge,
  .preview-ex-badges { display: none; }

  [contenteditable] { outline: none !important; background: transparent !important; }
  .preview-hint { display: none !important; }
}

/* === HARJOITTEET — tumma yläosa === */
#view-harjoitteet .view-header {
  background: #1e293b;
  border-bottom: 3px solid #334155;
}
#view-harjoitteet .filters-bar {
  background: transparent;
  border-bottom: none;
}
#view-harjoitteet .view-title {
  color: #fff !important;
}
#view-harjoitteet .view-desc {
  color: #94a3b8 !important;
}
#view-harjoitteet .results-count {
  color: #94a3b8 !important;
}
#view-harjoitteet .results-count span {
  color: #e2e8f0 !important;
}
#view-harjoitteet .filter-group-label {
  color: #e2e8f0 !important;
}
#view-harjoitteet .search-icon {
  color: #94a3b8;
}
#view-harjoitteet .active-filters-label {
  color: #94a3b8;
}
#view-harjoitteet .btn-clear-filters {
  background: #0f172a !important;
  color: #ffffff !important;
  border: 3px solid #0f172a !important;
  box-shadow: 3px 3px 0px rgba(0,0,0,0.4) !important;
}
#view-harjoitteet .btn-clear-filters:hover {
  background: #1e293b !important;
  color: #ffffff !important;
  border-color: #334155 !important;
  box-shadow: 5px 6px 0px rgba(0,0,0,0.4) !important;
}

/* === OHJELMAT — tumma teema === */
#view-ohjelmat .view-header {
  background: #1e293b;
  border-bottom: 3px solid #334155;
}
#view-ohjelmat .filters-bar {
  background: transparent;
  border-bottom: none;
}
#view-ohjelmat .view-title { color: #fff !important; }
#view-ohjelmat .view-desc  { color: #94a3b8 !important; }

#view-ohjelmat .category-heading {
  color: #e2e8f0 !important;
  border-bottom: 2px solid #334155;
  padding-bottom: 6px;
  margin-bottom: 12px;
}

#view-ohjelmat .program-card {
  background: #1e293b !important;
  border: 3px solid #334155 !important;
  box-shadow: 4px 4px 0px rgba(0,0,0,0.4) !important;
}
#view-ohjelmat .program-card:hover {
  box-shadow: 6px 7px 0px rgba(0,0,0,0.45) !important;
  border-color: #475569 !important;
}

#view-ohjelmat .program-title     { color: #f1f5f9 !important; }
#view-ohjelmat .program-freq      { color: #94a3b8 !important; }
#view-ohjelmat .program-desc      { color: #94a3b8 !important; }
#view-ohjelmat .program-details li { color: #cbd5e1 !important; }

#view-ohjelmat .program-category-badge {
  color: #7dd3fc !important;
  border-color: #7dd3fc !important;
  opacity: 0.85;
}

#view-ohjelmat .program-prescription {
  border-top: 1px solid #334155 !important;
}
#view-ohjelmat .prog-presc-item {
  background: #0f172a !important;
  border: 1px solid #334155 !important;
}
#view-ohjelmat .prog-presc-label { color: #64748b !important; }
#view-ohjelmat .prog-presc-val   { color: #e2e8f0 !important; }

#view-ohjelmat .client-instruction-section {
  border-top: 1px solid #334155 !important;
}
#view-ohjelmat .client-instruction-heading { color: #64748b !important; }
#view-ohjelmat .instruction-text {
  background: #0f172a !important;
  border: 1px solid #334155 !important;
  color: #cbd5e1 !important;
}

#view-ohjelmat .copy-btn {
  background: #0f172a !important;
  color: #7dd3fc !important;
  border: 2px solid #334155 !important;
}
#view-ohjelmat .copy-btn:hover {
  background: #1e293b !important;
  border-color: #475569 !important;
}

/* === DARK THEME OVERRIDES === */

/* Drill-chip: sama tummansininen tyyli kuin drill-all-btn */
.drill-chip {
  background: #0f172a !important;
  border-color: #0f172a !important;
  color: #ffffff !important;
  box-shadow: 3px 3px 0px rgba(0,0,0,0.4) !important;
}
.drill-chip:hover {
  background: #1e293b !important;
  border-color: #334155 !important;
  box-shadow: 5px 6px 0px rgba(0,0,0,0.4) !important;
  color: #ffffff !important;
}
.drill-chip.active {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #ffffff !important;
  box-shadow: 4px 4px 0px rgba(0,0,0,0.35) !important;
}
.drill-chip.active:hover {
  background: #f1f5f9 !important;
  box-shadow: 6px 7px 0px rgba(0,0,0,0.35) !important;
}

/* Drill-all-btn: tummansininen tausta, valkoinen teksti */
.drill-all-btn {
  background: #0f172a !important;
  border-color: #0f172a !important;
  color: #ffffff !important;
  box-shadow: 3px 3px 0px rgba(0,0,0,0.4) !important;
}
.drill-all-btn.has-selection {
  background: #0f172a !important;
  color: #ffffff !important;
  border-color: #0f172a !important;
}
.drill-all-btn:hover {
  background: #1e293b !important;
  border-color: #334155 !important;
  box-shadow: 5px 6px 0px rgba(0,0,0,0.4) !important;
}

/* Drill-back-btn */
.drill-back-btn {
  color: #94a3b8 !important;
  border-color: transparent !important;
  box-shadow: none !important;
}
.drill-back-btn:hover { color: #e2e8f0 !important; background: rgba(255,255,255,0.07) !important; }

/* Hakukenttä: comic-tyyli, valkoinen reunus */
.filter-search {
  background: #0f172a !important;
  color: #ffffff !important;
  border: 3px solid #ffffff !important;
  box-shadow: 4px 4px 0px rgba(255,255,255,0.25) !important;
}
.filter-search::placeholder { color: rgba(255,255,255,0.45) !important; opacity: 1 !important; }
.filter-search:focus {
  border-color: #ffffff !important;
  box-shadow: 6px 6px 0px rgba(255,255,255,0.3) !important;
}

/* Harjoitekortit: hieman vaaleampi sävy pohjasta */
.exercise-card {
  background: #1e293b !important;
  border-color: #334155 !important;
  box-shadow: 4px 4px 0px rgba(255,255,255,0.1) !important;
}
.exercise-card:hover {
  border-color: #64748b !important;
  box-shadow: 6px 7px 0px rgba(255,255,255,0.15) !important;
}
.exercise-card.selected {
  background: #1a3050 !important;
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.3), 4px 4px 0px rgba(255,255,255,0.1) !important;
}
.card-title { color: #f1f5f9 !important; }
.card-checkbox {
  background: #334155 !important;
  border-color: #475569 !important;
}
.exercise-card.selected .card-checkbox {
  background: #60a5fa !important;
  border-color: #60a5fa !important;
}

/* Dropdown-valikko tummassa teemassa */
.dropdown-menu {
  background: #1e293b !important;
  border: 1px solid #334155 !important;
  box-shadow: 4px 8px 24px rgba(0,0,0,0.5) !important;
}
.dropdown-item { color: #ffffff !important; }
.dropdown-item:hover { background: rgba(255,255,255,0.07) !important; color: #fff !important; }
.dropdown-label { color: #ffffff !important; }
.dropdown-desc { color: #ffffff !important; }

/* === GLOBAL WHITE TEXT — kaikki tekstit valkoisiksi === */
* { color: #ffffff !important; }

/* Poikkeukset: elementit joilla tarvitaan tumma teksti */
.drill-chip.active,
.drill-all-btn.has-selection,
.create-btn,
.exercise-card.selected .card-checkbox svg { color: #0f172a !important; }

/* Placeholder */
::placeholder { color: rgba(255,255,255,0.45) !important; opacity: 1 !important; }

/* === RESPONSIVE === */
@media (max-width: 640px) {
  .app { padding: 20px 16px 80px; }
  .header-inner { padding: 0 16px; }
  .exercise-grid { grid-template-columns: 1fr; }
  .selection-panel { padding: 12px 16px; }
  .filters-row { gap: 0.4rem; }
  .filter-input, .filter-select { min-width: 100%; }
}

/* === PAKKOMUUTOS: kaikki tekstit valkoisia, inputit tummia === */
* {
  color: #ffffff !important;
}
input, textarea, select {
  background: #0f172a !important;
  color: #ffffff !important;
  border: 3px solid #ffffff !important;
}
::placeholder {
  color: rgba(255,255,255,0.6) !important;
  opacity: 1 !important;
}
/* Poikkeukset tummalle tekstille */
.drill-chip.active,
.drill-all-btn.has-selection {
  color: #0f172a !important;
}
