/* Lokale Einbindung der Schriftart Inter */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/inter_24pt-Regular.ttf') format('truetype');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('fonts/inter_24pt-Bold.ttf') format('truetype');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('fonts/inter_24pt-ExtraBold.ttf') format('truetype');
}

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 900;
  font-display: swap;
  src: url('fonts/inter_24pt-Black.ttf') format('truetype');
}

/* Dein restlicher CSS-Code beginnt hier */
:root {
  --bg: #ffffff;
  --fg: #111827;
  --muted: #6b7280;
  --border-color: #e5e7eb;
  --ok: #16a34a; /* Green for success */
  --bad: #ef4444;  /* Red for failure */
  --miss: #e5e7eb; /* Light gray for missed */
  --bronze: #cd7f32;
  --silver: #aaa9ad;
  --gold: #daa520;
  --zebra-bg-dark: #e5e7eb;

  /* Text colors */
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;

  /* Background colors */
  --bg-secondary: #f9fafb;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* Prevent horizontal scrolling */
}

body.modal-open {
    overflow: hidden;
}

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 16px;
  overflow-x: hidden; /* Prevent horizontal scrolling */
}

.card {
  background: var(--bg);
  border: 1px solid var(--border-color);
  border-radius: 12px; /* Rounded corners */
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

header {
  text-align: center;
  margin-bottom: 14px;
  position: relative;
}

.language-switcher {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 10;
}
.language-switcher select {
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background-color: var(--bg);
    font-family: inherit;
    font-weight: 700;
    cursor: pointer;
}

h1 {
  margin: 0 0 6px;
  font-weight: 900;
  font-size: clamp(1.5rem, 2.2vw + 1rem, 2.2rem);
}

h2 {
  font-weight: 800;
  font-size: 1.25rem;
}

h3.section-header {
    text-align: left;
    margin-top: 24px;
    margin-bottom: 12px;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.preset-category-header {
    background-color: #f3f4f6;
    padding: 12px 16px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    margin-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.muted {
  color: var(--muted);
}

.row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
}

.checkin-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  align-items: center;
  margin: 6px 0;
}

/* --- Check-in Styles --- */
.habit-button-container.split-view {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.split-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    flex-grow: 1;
}
.split-actions.single-action {
    grid-template-columns: 1fr;
}
.split-info {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-weight: 700;
    white-space: nowrap;
}
.habit-button-container.inactive-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 4px;
    border-radius: 8px;
    background-color: #f8f9fa;
    color: var(--muted);
    font-weight: 700;
}
.inactive-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}
.habit-info-icon.inactive {
    color: var(--muted);
    font-size: 1.2rem;
}
.habit-info-icon.inactive:hover {
    color: var(--fg);
}
.inactive-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.pattern-info {
    font-size: 0.8rem;
    color: var(--muted);
}
.due-date-info {
    font-size: 0.9rem;
    font-weight: 700;
}
.checkin-row-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    width: 100%;
    align-items: center;
}

.btn {
  appearance: none;
  border: 1px solid var(--border-color);
  border-radius: 8px; /* Rounded buttons */
  padding: 12px 16px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  background-color: var(--bg);
  color: var(--fg);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: 100%;
  box-sizing: border-box;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  position: relative;
}

.btn-icon {
    padding: 8px 12px;
    width: auto;
    font-size: 1.2rem;
    line-height: 1;
}

#btn-manage-habits {
    width: auto !important;
    display: inline-block !important;
    padding: 10px 20px !important;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    background-color: #10b981 !important;
    color: white !important;
    border: none !important;
    border-radius: 8px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.5px !important;
}

.btn:hover:not(:disabled) {
  background-color: var(--fg);
  color: var(--bg);
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-ok:not(:hover) { background-color: var(--ok); color: white; border-color: var(--ok); }
.btn-bad:not(:hover) { background-color: var(--bad); color: white; border-color: var(--bad); }

.btn-confirm-reset, .btn-danger { border-color: var(--bad); color: var(--bad); }
.btn-confirm-reset:hover, .btn-danger:hover { background-color: var(--bad); color: var(--bg); }

.status-done {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    font-weight: 700;
    margin-bottom: 0;
    text-align: center;
    background-color: #f8f9fa;
    color: var(--fg);
}

.status-done.ok {
    border-color: var(--ok);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(22, 163, 74, 0.15) 10px, rgba(22, 163, 74, 0.15) 20px);
}

.status-done.bad {
    border-color: var(--bad);
    background-image: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(239, 68, 68, 0.15) 10px, rgba(239, 68, 68, 0.15) 20px);
}

/* --- Counter Button Styles --- */
.btn-counter {
    background-color: var(--bad);
    border: none;
    color: var(--fg);
    padding: 12px 16px;
    transition: all 0.3s ease;
}
.btn-counter .progress-bar {
    background-color: var(--ok);
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    transition: width 0.3s ease, background-color 0.3s ease;
    z-index: 1;
    border-radius: 6px;
}
.btn-counter .progress-bar.limit {
    background-color: var(--bad);
    left: auto;
    right: 0;
}
.btn-counter .progress-text {
    position: relative;
    z-index: 2;
    color: white;
    text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.btn-counter .ticks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size: cover;
    opacity: 0.1;
    z-index: 1;
}
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}
.popped { animation: pop 0.3s ease-out; }

/* --- Info Icon & Tooltip Styles --- */
.habit-button-container {
    position: relative;
    display: flex;
    align-items: center;
}
.habit-info-icon {
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    color: var(--muted);
    margin-left: 10px;
    padding: 4px;
    line-height: 1;
    user-select: none;
}
.habit-info-icon:hover { color: var(--fg); }
.tooltip {
    visibility: hidden; width: 220px; background-color: var(--fg); color: var(--bg);
    text-align: center; border-radius: 6px; padding: 8px; position: absolute;
    z-index: 100; bottom: 125%; left: 50%; margin-left: -110px; opacity: 0;
    transition: opacity 0.3s; font-size: 0.85rem; font-weight: 400; line-height: 1.4;
    text-transform: none; letter-spacing: normal;
}
.tooltip::after {
    content: ""; position: absolute; top: 100%; left: 50%; margin-left: -5px;
    border-width: 5px; border-style: solid; border-color: var(--fg) transparent transparent transparent;
}
.tooltip.visible { visibility: visible; opacity: 1; }

/* --- New Icon Tooltip System --- */
.icon-tooltip {
    position: fixed;
    background-color: var(--fg);
    color: var(--bg);
    border-radius: 8px;
    padding: 12px 16px;
    z-index: 1000;
    max-width: 280px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.icon-tooltip-title {
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 6px;
}

.icon-tooltip-description {
    font-size: 0.9rem;
    line-height: 1.4;
    opacity: 0.9;
}

.icon-tooltip-description:empty {
    display: none;
}

.habit-icon-clickable {
    cursor: pointer;
    transition: transform 0.2s ease, opacity 0.2s ease;
    user-select: none;
}

.habit-icon-clickable:hover {
    transform: scale(1.1);
    opacity: 0.8;
}

.habit-icon-clickable:active {
    transform: scale(0.95);
}

#focus {
  margin-bottom: 22px;
}

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.metric-card {
  border: 1px solid var(--border-color); 
  border-radius: 12px; 
  padding: 24px; 
  display: flex;
  align-items: center; 
  justify-content: space-between; 
  gap: 24px; 
  transition: all 0.3s ease-in-out;
  position: relative;
  background-color: var(--bg);
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
}

.metric-card.streak-zero {
  background-image: repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(0, 0, 0, 0.08) 4px, rgba(0, 0, 0, 0.08) 8px);
}

.metric-card.dark-bg,
.metric-card-horizontal.dark-bg,
.metric-card.dark-bg .streak-number,
.metric-card-horizontal.dark-bg .streak-number,
.metric-card.dark-bg .best-streak,
.metric-card-horizontal.dark-bg .best-streak,
.metric-card-horizontal.dark-bg .best-streak-number,
.metric-card.dark-bg .progress-ring-text,
.metric-card-horizontal.dark-bg .progress-ring-text,
.metric-card.dark-bg .habit-name,
.metric-card-horizontal.dark-bg .habit-name,
.metric-card.dark-bg .streak-title,
.metric-card-horizontal.dark-bg .streak-title,
.metric-card-horizontal.dark-bg .habit-name-header,
.metric-card-horizontal.dark-bg .current-streak-number,
.metric-card-horizontal.dark-bg .cell-streak,
.metric-card-horizontal.dark-bg .habit-info-text,
.metric-card-horizontal.dark-bg .metric-label {
    color: var(--bg);
}

.metric-card.dark-bg .streak-title.bronze,
.metric-card-horizontal.dark-bg .streak-title.bronze,
.metric-card.dark-bg .streak-title.silver,
.metric-card-horizontal.dark-bg .streak-title.silver,
.metric-card.dark-bg .streak-title.gold,
.metric-card-horizontal.dark-bg .streak-title.gold {
    color: var(--bg);
    opacity: 0.9;
}

.metric-card.dark-bg .habit-name .habit-info-icon,
.metric-card-horizontal.dark-bg .habit-name .habit-info-icon {
    color: #e5e7eb;
}
.metric-card.dark-bg .habit-name .habit-info-icon:hover,
.metric-card-horizontal.dark-bg .habit-name .habit-info-icon:hover {
    color: var(--bg);
}

.metric-card.dark-bg .progress-ring-bg,
.metric-card-horizontal.dark-bg .progress-ring-bg {
    stroke: rgba(255, 255, 255, 0.3);
}
.metric-card.dark-bg .progress-ring-notches circle,
.metric-card-horizontal.dark-bg .progress-ring-notches circle {
    stroke: rgba(255, 255, 255, 0.5);
}
.metric-card.dark-bg .progress-ring-border-outer,
.metric-card-horizontal.dark-bg .progress-ring-border-outer,
.metric-card.dark-bg .progress-ring-border-inner,
.metric-card-horizontal.dark-bg .progress-ring-border-inner {
    stroke: var(--bg);
}

/* Make SVG text white on dark backgrounds */
.metric-card-horizontal.dark-bg text,
.metric-card-horizontal.dark-bg svg,
.metric-card-horizontal.dark-bg .gauge-svg text {
    fill: var(--bg) !important;
}

/* Make buttons visible on dark background */
.metric-card-horizontal.dark-bg button svg {
    stroke: var(--bg);
    fill: none !important;
}

/* Make milestone info text white on dark background */
.metric-card-horizontal.dark-bg .cell-status > div,
.metric-card-horizontal.dark-bg [id^="next-milestone-"],
.metric-card-horizontal.dark-bg [id^="streak-title-"] {
    color: var(--bg) !important;
}

/* Make habit icon white on dark background */
.metric-card-horizontal.dark-bg .habit-icon-wrapper img,
.metric-card-horizontal.dark-bg .habit-icon-clickable {
    filter: brightness(0) invert(1);
}

/* Challenge Card Styles */
.metric-card-challenge {
    border: 3px solid #daa520; /* Golden border */
    box-shadow: 0 4px 16px rgba(218, 165, 32, 0.3), 0 2px 8px rgba(218, 165, 32, 0.2);
    background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(255, 250, 220, 0.7) 100%);
    position: relative;
    padding-top: 50px; /* Extra space for the challenge banner */
}

.challenge-banner {
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    background: linear-gradient(135deg, #4b5563, #374151);
    color: white;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 700;
    text-align: center;
    border-radius: 11px 11px 0 0;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Challenge styles for Habit Check section */
.habit-wrapper-challenge {
    border: 3px solid #daa520 !important;
    box-shadow: 0 4px 16px rgba(218, 165, 32, 0.3), 0 2px 8px rgba(218, 165, 32, 0.2);
    background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(255, 250, 220, 0.7) 100%);
}

/* Note: We no longer hide habit-info-text for challenges, because weekly/monthly habits
   with specific days need to show the rule (e.g. "Jeden Mo, Fr • ...") */

/* --- Horizontal Card Layout --- */
.metric-card-horizontal {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    background-color: var(--bg);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    margin-bottom: 16px;
    position: relative;
    overflow: hidden; /* Ensure content stays within rounded corners */
}

/* New 'Energy Flow' animation class */
.energy-flow-animation {
    border: 2px solid transparent; /* Make border thicker to be visible */
    --angle: 0deg;
    border-image: conic-gradient(from var(--angle), transparent, #3b82f6, transparent 25%) 1;
    animation: energy-flow 3s linear infinite;
}

.metric-card-horizontal.metric-card-challenge {
    padding-top: 42px;
}

/* Habit Name Header - positioned at top left with icon */
.habit-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-color);
}

.habit-card-header img {
    width: 22px;
    height: 22px;
}

.habit-name-header {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.habit-card-header button:first-of-type {
    margin-left: auto;
}

/* Grid Layout: 3 rows × 5 columns (POWER, STREAK, BOOST, BEST) */
.habit-card-content {
    display: grid;
    grid-template-columns: 120px 150px 90px 90px 1fr;
    grid-template-rows: auto auto auto;
    gap: 0;
    width: 100%;
    align-items: center;
}

/* Row 1, Col 1: Gauge */
.cell-gauge {
    grid-column: 1;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gauge-svg {
    display: block;
}

/* Row 1, Col 2: Streak Number */
.cell-streak {
    grid-column: 2;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Row 1, Col 3: Boost Number */
.cell-boost {
    grid-column: 3;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Row 1, Col 4: Best Number */
.cell-best {
    grid-column: 4;
    grid-row: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Row 2, Col 1: Power Label */
.cell-label-power {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
}

/* Row 2, Col 2: Streak Label */
.cell-label-streak {
    grid-column: 2;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
}

/* Row 2, Col 3: Boost Label */
.cell-label-boost {
    grid-column: 3;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
}

/* Row 2, Col 4: Best Label */
.cell-label-best {
    grid-column: 4;
    grid-row: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 0;
}

/* Row 3, Col 1-4: Status Text */
.cell-status {
    grid-column: 1 / 5;
    grid-row: 3;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    padding: 4px 12px 0 12px;
}

/* Number styling */
.current-streak-number {
    font-size: 74px;
    font-weight: 900;
    color: var(--fg);
    line-height: 1;
    text-align: center;
}

.boost-number {
    font-size: 44px;
    font-weight: 800;
    color: var(--fg);
    line-height: 1;
    text-align: center;
}

.best-streak-number {
    font-size: 44px;
    font-weight: 800;
    color: var(--fg);
    line-height: 1;
    text-align: center;
}

/* Label styling */
.metric-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1;
}

/* Monochrome design - no colored backgrounds */
.metric-card-horizontal {
    background-color: var(--bg);
    padding: 12px 16px;
}

.metric-card-horizontal.streak-zero {
    background-image: repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(0, 0, 0, 0.08) 4px, rgba(0, 0, 0, 0.08) 8px);
}

/* --- NEW: Combined Card Layout --- */
.metric-card-combined {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px;
    background-color: var(--bg);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.metric-card-combined.streak-zero {
    background-image: repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(0, 0, 0, 0.08) 4px, rgba(0, 0, 0, 0.08) 8px);
}

.metric-card-combined.metric-card-challenge {
    padding-top: 42px;
}

/* Main Grid Layout */
.habit-card-main-grid {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 20px;
    align-items: start;
}

.reserved-space-left {
    width: 160px;
    height: 100%;
    /* Reserved for future pixel art - MAXIMUM SPACE */
}

.habit-card-content-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Header with Icon + Name + Buttons (smaller, shifted right) */
.habit-card-header-combined {
    display: flex;
    align-items: center;
    gap: 8px;
}

.habit-card-header-combined .habit-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
}

.habit-name-combined {
    flex: 1;
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--fg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.habit-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    opacity: 0.6;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.habit-action-btn:hover {
    opacity: 1;
}

/* Stats Container - LARGER and More Compact */
.stats-container {
    display: flex;
    align-items: flex-end;
    justify-content: flex-start;
    gap: 24px;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex: 0 0 auto;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--fg);
    line-height: 1;
    height: 2.5rem;
    display: flex;
    align-items: center;
}

.stat-label {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    line-height: 1;
}

.stat-gauge-mini {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 2.5rem;
}

/* Power Progressbar */
.stat-item-power {
    flex: 0 0 auto;
    width: 180px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.power-progressbar {
    width: 100%;
    display: flex;
    align-items: center;
    height: 2.5rem;
}

.power-progressbar-bg {
    width: 100%;
    height: 48px;
    background-color: #f5f5f5;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(0, 0, 0, 0.08) 4px,
        rgba(0, 0, 0, 0.08) 8px
    );
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.power-progressbar-fill {
    height: 100%;
    background-color: #ef4444;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(255, 255, 255, 0.25) 4px,
        rgba(255, 255, 255, 0.25) 8px
    );
    border-radius: 0;
    transition: width 0.5s ease, background-color 0.3s ease;
    position: absolute;
    left: 0;
    top: 0;
    min-width: 0;
}

.power-progressbar-text {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
}

/* Badge Progress Text - Left Aligned */
.badge-progress-text {
    font-size: 0.85rem;
    color: var(--fg);
    text-align: left;
    font-weight: 500;
    margin-top: 4px;
}

/* Action Buttons - Smaller */
.habit-action-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Status blocks in combined cards - same spacing as buttons */
.habit-action-buttons .habit-status-block {
    width: 100%;
    box-sizing: border-box;
}

.action-buttons-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.action-buttons-row .btn {
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 600;
}

.action-buttons-row .btn.disabled,
.habit-action-buttons .btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Dark background adjustments for combined card */
.metric-card-combined.dark-bg {
    color: var(--bg);
}

.metric-card-combined.dark-bg .habit-name-combined,
.metric-card-combined.dark-bg .stat-value,
.metric-card-combined.dark-bg .stat-label,
.metric-card-combined.dark-bg .badge-progress-text {
    color: var(--bg);
}

.metric-card-combined.dark-bg .habit-action-btn svg {
    stroke: var(--bg);
}

.metric-card-combined.dark-bg .gauge-svg-mini text {
    fill: var(--bg) !important;
}

.metric-card-combined.dark-bg .power-progressbar-bg {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Responsive: Keep horizontal layout but make it compact on mobile */
@media (max-width: 600px) {
    .metric-card-horizontal {
        padding: 12px;
        margin-bottom: 8px;
        border-radius: 8px;
    }

    .habit-card-header {
        gap: 8px;
        margin-bottom: 10px;
        padding-bottom: 6px;
    }

    .habit-card-header img {
        width: 20px;
        height: 20px;
    }

    .habit-name-header {
        font-size: 0.9rem;
    }

    .metric-card-horizontal {
        padding: 10px 12px;
    }

    .habit-card-content {
        grid-template-columns: 90px 100px 60px 60px 1fr;
        grid-template-rows: auto auto auto;
        gap: 0;
    }

    /* Mobile adjustments for new combined card layout */
    .habit-card-main-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .reserved-space-left {
        display: none;
    }

    .metric-card-combined {
        padding: 12px;
    }

    .habit-card-content-area {
        gap: 10px;
    }

    .habit-card-header-combined .habit-icon {
        width: 32px;
        height: 32px;
    }

    .habit-name-combined {
        font-size: 1.1rem;
    }

    .stats-container {
        gap: 8px;
        flex-wrap: nowrap;
        justify-content: space-between;
    }

    .stat-value {
        font-size: 1.8rem;
        height: 1.8rem;
    }

    .stat-label {
        font-size: 0.55rem;
    }

    .stat-item-power {
        width: auto;
        flex: 1 1 auto;
        min-width: 100px;
    }

    .power-progressbar-bg {
        height: 36px;
    }

    .power-progressbar-text {
        font-size: 1rem;
        left: 8px;
    }

    .action-buttons-row {
        gap: 6px;
    }

    .action-buttons-row .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .gauge-svg {
        width: 70px !important;
        height: auto !important;
    }

    .current-streak-number {
        font-size: 2rem;
    }

    .boost-number {
        font-size: 1.5rem;
    }

    .best-streak-number {
        font-size: 1.5rem;
    }

    .metric-label {
        font-size: 0.6rem;
    }

    .cell-status {
        padding: 0 8px;
    }

    .cell-status div {
        font-size: 0.8rem !important;
        line-height: 1.2 !important;
    }
}

.habit-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fg);
    margin-bottom: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    text-wrap: balance;
}

.habit-name .habit-info-icon {
    font-size: 1.2rem;
    margin-left: 0;
    padding: 0;
    line-height: 1;
    cursor: pointer;
    color: var(--muted);
    user-select: none;
}
.habit-name .habit-info-icon:hover { color: var(--fg); }

.habit-name .tooltip {
    bottom: auto;
    top: calc(100% + 8px);
    left: 50%;
    margin-left: -110px;
}
.habit-name .tooltip::after {
    top: -10px;
    bottom: auto;
    left: 50%;
    margin-left: -5px;
    border-color: transparent transparent var(--fg) transparent;
}
.progress-ring { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.progress-ring-svg { transform: rotate(-90deg); width: 100%; height: 100%; }

.progress-ring-circle {
  transition: stroke-dashoffset 0.3s ease, stroke 0.3s ease;
  fill: transparent;
  stroke-linecap: round;
  stroke-width: 14;
}

.progress-ring-bg { stroke: var(--miss); stroke-width: 14; fill: transparent; }
.progress-ring-text {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-weight: 700; font-size: 1.5rem;
}
.streak-display { text-align: center; flex-grow: 1; display: flex; flex-direction: column; justify-content: center; }
.streak-number {
  font-size: clamp(3.5rem, 16vw, 6rem); font-weight: 900; line-height: 1;
  letter-spacing: .5px; white-space: nowrap; color: var(--fg);
}
.streak-title {
  font-size: clamp(.9rem,1.5vw+.7rem,1.1rem); line-height: 1.2;
  text-wrap: balance; margin-top: 6px; min-height: 1.2em; /* Reserve space for milestone text */
}
.streak-title.bronze { color: var(--bronze); font-weight: 700; }
.streak-title.silver { color: var(--silver); font-weight: 700; }
.streak-title.gold { color: var(--gold); font-weight: 700; }
.best-streak { font-size: 0.85rem; color: var(--muted); margin-top: 8px; font-weight: 700; }
#calendar-card { display: flex; flex-direction: column; }
.calendar-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; width: 100%;
}
.calendar-header h2 { margin: 0; font-size: 1.5rem; text-align: center; flex-grow: 1; }
.btn-nav {
  background: transparent; border: none; font-size: 1.5rem; font-weight: bold;
  padding: 4px 12px; width: auto;
}
.btn-nav:hover:not(:disabled) { background-color: var(--miss); color: var(--fg); transform: none; box-shadow: none; }
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.weekday { font-weight: 700; text-align: center; color: var(--muted); font-size: 0.8rem; padding-bottom: 10px; }
.calendar-day {
  min-height: 70px; border: 1px solid var(--border-color); border-radius: 6px; padding: 4px;
  display: flex; flex-direction: column; justify-content: space-between;
  cursor: pointer; transition: background-color 0.3s ease; position: relative;
}
.calendar-day:hover { background-color: #f8f9fa; }
.calendar-day.disabled { cursor: not-allowed; background-color: #f8f9fa; opacity: 0.7; }
.calendar-day.disabled:hover { background-color: #f8f9fa; }
.calendar-day.other-month { visibility: hidden; }
.calendar-day.today {
  border: 2px solid var(--fg);
  background-image: repeating-linear-gradient(45deg, transparent, transparent 4px, rgba(0, 0, 0, 0.08) 4px, rgba(0, 0, 0, 0.08) 8px);
}
.day-header { display: flex; justify-content: space-between; width: 100%; align-items: flex-start; }
.day-number {
  font-size: 0.8rem; font-weight: 700; color: var(--fg); mix-blend-mode: difference;
  filter: invert(1) grayscale(1) contrast(100); padding: 2px;
}
.day-awards { display: flex; gap: 2px; }
.day-awards span { font-size: 14px; }
.day-segments {
  display: flex; flex-wrap: wrap; justify-content: flex-start; gap: 4px; height: auto; margin-top: auto;
}
.day-segments .seg {
  width: 20px; height: 20px; border-radius: 4px; display: flex;
  align-items: center; justify-content: center; font-size: 16px;
  position: relative;
}
.day-segments .seg .seg-icon {
  width: 16px;
  height: 16px;
  object-fit: contain;
  filter: brightness(0) invert(1); /* Make icon white */
}
.day-segments .seg.ok { background: var(--ok); }
.day-segments .seg.bad { background: var(--bad); }
.day-segments .seg.miss { background: var(--miss); }
.day-segments .seg.missed { background: #9ca3af; } /* Gray for forgotten rotating weekday habits */
.day-segments .seg.partial-success { background: linear-gradient(45deg, var(--ok) 50%, var(--bad) 50%); }
.day-segments .seg.not-due { background-color: transparent; border: 1px dashed var(--border-color); }
.dark-bg .day-segments .seg { background: transparent !important; border-width: 2px; border-style: solid; }
.dark-bg .day-segments .seg.ok:not(.badge) { border-color: #ffffff; }
.dark-bg .day-segments .seg.bad { border-color: #fca5a5; }
.dark-bg .day-segments .seg.miss { border-color: #a1a1aa; }
.dark-bg .day-segments .seg.missed { border-color: #9ca3af; }
.dark-bg .day-segments .seg.partial-success { background: linear-gradient(45deg, #ffffff 50%, #fca5a5 50%) !important; border: 2px solid #ffffff; }
.dark-bg .day-segments .seg.not-due { border-color: rgba(255, 255, 255, 0.3); }
.dark-bg .day-segments .seg.badge { border: none; }

/* Enhanced visibility for calendar days with dark backgrounds */
.calendar-day.dark-bg .day-number {
    color: #ffffff !important;
    mix-blend-mode: normal;
    filter: none;
}

.calendar-day.dark-bg:hover {
    filter: brightness(1.15);
}

.legend-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 5px; margin-top: 12px; }
#legend-habits span { display: inline-flex; align-items: center; position: relative; }
.legend-separator { margin: 0 8px; }
.playground-container {
  position: relative; width: 100%; aspect-ratio: 1 / 1; background-size: contain;
  background-repeat: no-repeat; background-position: center; border: 1px solid var(--border-color);
  transition: background-image 0.5s ease-in-out; background-color: #f0f0f0; border-radius: 8px;
}
#level-change-indicator { margin-left: 8px; font-weight: bold; }
.level-up { color: var(--ok); }
.level-down { color: var(--bad); }
.level-same { color: var(--muted); }
#danger .btn, #reset-modal .btn { width: auto; }
#settings-modal, #reset-modal, #edit-day-modal, #delete-modal, #delete-habit-dashboard-modal, #delete-habit-permanently-modal, #support-modal, #habit-stats-modal, #reminder-modal, #legal-modal {
  display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%;
  overflow: auto; background-color: rgba(0,0,0,0.5); align-items: center; justify-content: center;
}
.modal-content {
  background-color: #fefefe; padding: 24px; border: 1px solid var(--border-color); border-radius: 12px;
  max-width: 500px; text-align: center; width: 90%; max-height: 90vh; overflow-y: auto;
}
#settings-modal .modal-content {
    background-color: var(--zebra-bg-dark);
}
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }

.setting-item, .edit-item { 
    background: var(--bg);
    border: 1px solid var(--border-color); 
    border-radius: 12px; 
    padding: 16px; 
    text-align: left;
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    margin-bottom: 16px;
}

.setting-item-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.setting-item-header h4 { margin: 0; font-size: 1.1rem; }
.setting-item-actions { display: flex; gap: 8px; }
.archived-item { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; }
.setting-item label, .edit-item-label { font-weight: 700; display: block; margin-bottom: 8px; }
.setting-item input[type="text"], .setting-item textarea, .setting-item input[type="number"], .edit-item input[type="number"] {
  width: 100%; padding: 8px; box-sizing: border-box; border: 1px solid var(--border-color);
  border-radius: 6px; font-size: 1rem; font-family: inherit;
}
.setting-item textarea { min-height: 80px; resize: vertical; }
.edit-controls { display: flex; gap: 10px; }
.edit-controls .btn { flex-grow: 1; }
.edit-controls .edit-count-input {
    width: 100px; text-align:center; font-size: 1.2rem; padding: 10px;
}
.edit-controls .btn, #settings-modal .btn, #delete-modal .btn { width: auto; }

.toggle-description {
    cursor: pointer;
    font-weight: 700;
    color: var(--fg);
    text-decoration: underline;
    margin-left: 4px;
}

.preset-buttons {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 10px !important;
    margin-top: 16px !important;
    min-height: 100px !important;
}

.preset-buttons .btn {
    height: auto !important;
    min-height: 80px !important;
    width: auto !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    justify-content: space-between !important;
    padding: 12px !important;
    text-transform: none !important;
    font-size: 0.85rem !important;
    background-color: var(--muted) !important;
    color: white !important;
    border: 1px solid var(--border-color) !important;
    text-align: left !important;
}

.preset-buttons .btn:hover:not(:disabled) {
    background-color: var(--fg);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.preset-buttons .btn strong {
    font-weight: 800;
    font-size: 1rem;
    margin-bottom: 4px;
    display: block;
}

.preset-buttons .btn small {
    font-size: 0.75rem;
    opacity: 0.8;
    line-height: 1.3;
}

.preset-buttons .btn .preset-type {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    opacity: 0.9;
    align-self: flex-end;
    margin-top: 8px;
}


@media (max-width:900px){.grid{grid-template-columns:1fr}}
@media (max-width:600px){
    .grid, .settings-grid {grid-template-columns:1fr}
    .metric-card { text-align: center; gap: 24px; padding: 24px; flex-direction: column; }
    .progress-ring { width: 120px; height: 120px; }
    .streak-number { font-size: clamp(3rem, 20vw, 5rem); }
    .calendar-day { min-height: 60px; padding: 4px; }
    .day-number { font-size: 0.7rem; }
    .day-awards span { font-size: 12px; }
    .day-segments { gap: 2px; }
    .day-segments .seg { width: 12px; height: 12px; border-radius: 2px; font-size: 10px; }
    .day-segments .seg .seg-icon { width: 10px; height: 10px; }
    .language-switcher { top: 8px; right: 8px; }
    .preset-buttons { grid-template-columns: repeat(2, 1fr); }

    .btn {
        font-size: 0.7rem; /* Noch kleinere Schriftgröße für Mobilgeräte */
    }
}

/* --- Footer & Legal Links --- */
.page-footer {
  text-align: center;
  margin-top: 40px;
  padding: 20px;
  color: var(--muted);
}

.footer-separator {
  margin: 0 8px;
}

.btn-link {
  background: none;
  border: none;
  color: var(--muted);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  padding: 0;
  font-size: 0.9rem;
}

.btn-link:hover {
  text-decoration: underline;
  color: var(--fg);
}

a.btn-link {
    text-decoration: none;
}

/* --- Style for text in legal modals --- */
.modal-content .text-block {
  text-align: left;
  line-height: 1.6;
}

.modal-content .text-block h3 {
  margin-top: 24px;
}

/* --- Style for new legal pages --- */
.legal-content {
  background: var(--bg);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 22px;
  box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  text-align: left;
  line-height: 1.6;
}

.legal-content h3 {
    margin-top: 24px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.back-link {
    display: inline-block;
    margin-bottom: 20px;
    font-weight: 700;
    text-decoration: none;
    color: var(--fg);
}

.back-link:hover {
    text-decoration: underline;
}

/* --- Setup Page Custom Styles --- */
.setup-primary-card {
    background-color: var(--muted);
    color: var(--bg);
    border: none;
}
.setup-primary-card h2 { color: var(--bg); }
.setup-primary-card p.muted { color: #e5e7eb; }
.setup-primary-card .setting-item {
    background: rgba(0, 0, 0, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}
.setup-primary-card .setting-item-header h4 { color: var(--bg); }
.setup-primary-card .setting-item-header .btn-danger {
    background-color: var(--bad); color: var(--bg); border: none;
}
.setup-primary-card .setting-item-header .btn-danger:hover { opacity: 0.8; }
.setup-primary-card .setting-item label { color: #d1d5db; }
.setup-primary-card .setting-item input[type="text"],
.setup-primary-card .setting-item textarea,
.setup-primary-card .setting-item select {
    background-color: rgba(0,0,0,0.2); color: var(--bg); border-color: rgba(255, 255, 255, 0.3);
}
.setup-primary-card .setting-item input[type="text"]:focus,
.setup-primary-card .setting-item textarea:focus,
.setup-primary-card .setting-item select:focus {
    outline: 2px solid var(--ok); border-color: var(--ok);
}
.setup-primary-card #btn-add-setup-habit {
    background-color: rgba(255, 255, 255, 0.1); color: var(--bg); border-color: rgba(255, 255, 255, 0.3);
}
.setup-primary-card #btn-add-setup-habit:hover { background-color: rgba(255, 255, 255, 0.2); }
#btn-finish-setup.btn-start {
    background-color: var(--ok); color: white; border-color: var(--ok); flex-grow: 1;
    font-size: 1.1rem; padding-top: 14px; padding-bottom: 14px;
}
#btn-finish-setup.btn-start:hover {
    background-color: #15803d; border-color: #15803d; color: white;
}
#btn-finish-setup.btn-start:disabled {
    background-color: rgba(0,0,0,0.2); border-color: rgba(255, 255, 255, 0.1); color: rgba(255, 255, 255, 0.4);
}

/* --- Habit Type & Frequency Styles --- */
.habit-type-selector {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 8px;
}
.type-btn {
    padding: 12px 8px; font-size: 0.8rem; text-transform: none; height: auto;
    white-space: normal; text-align: center; line-height: 1.3; border: 2px solid transparent;
}
.setting-item:not(.setup-primary-card .setting-item) .type-btn {
    background-color: #f3f4f6; color: var(--fg); border-color: var(--border-color);
}
.setting-item:not(.setup-primary-card .setting-item) .type-btn:hover { background-color: #e5e7eb; }
.setting-item:not(.setup-primary-card .setting-item) .type-btn.active {
    background-color: var(--fg); color: var(--bg); border-color: var(--fg); font-weight: 700;
}
.setup-primary-card .type-btn {
    background-color: rgba(0,0,0,0.2); color: #e5e7eb; border-color: rgba(255, 255, 255, 0.3);
}
.setup-primary-card .type-btn:hover { background-color: rgba(0,0,0,0.4); }
.setup-primary-card .type-btn.active {
    background-color: var(--bg); color: var(--fg); border-color: var(--bg); font-weight: 700;
}
.freq-options {
    margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255, 255, 255, 0.2);
}
.setting-item:not(.setup-primary-card .setting-item) .freq-options {
    border-top: 1px solid var(--border-color);
}
.sub-selector { grid-template-columns: 1fr 1fr !important; }

.freq-weekly-days {
    display: block;
    margin-top: 8px;
}
.freq-monthly-date {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    margin-top: 8px;
    max-width: 300px;
    margin-left: auto;
    margin-right: auto;
}
.freq-monthly-info {
    font-size: 0.8rem;
    margin-top: 8px;
    line-height: 1.4;
    text-align: center;
}
.day-btn {
    padding: 2px;
    font-size: 0.7rem;
    background-color: #f3f4f6;
    color: var(--fg);
    border: 2px solid var(--border-color);
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.setup-primary-card .day-btn {
     background-color: rgba(0,0,0,0.2); color: #e5e7eb; border-color: rgba(255, 255, 255, 0.3);
}
.day-btn:hover { background-color: #e5e7eb; }
.setup-primary-card .day-btn:hover { background-color: rgba(0,0,0,0.4); }
.day-btn.active { background-color: var(--fg); color: var(--bg); border-color: var(--fg); }
.setup-primary-card .day-btn.active { background-color: var(--bg); color: var(--fg); border-color: var(--bg); }

/* Duration Button Styling - Consistent with inactive buttons (custom color #4D515C) */
.duration-preset-selector .btn.duration-btn,
.duration-custom .btn.duration-btn {
    padding: 8px 12px !important;
    border: 1px solid #7E8493 !important;
    border-radius: 6px !important;
    background-color: #4D515C !important;
    color: #e5e7eb !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-transform: none !important;
    letter-spacing: normal !important;
    font-size: 14px !important;
}
.duration-preset-selector .btn.duration-btn:hover,
.duration-custom .btn.duration-btn:hover {
    background-color: #374151 !important;
    color: #e5e7eb !important;
}
.setup-primary-card .duration-preset-selector .btn.duration-btn:hover,
.setup-primary-card .duration-custom .btn.duration-btn:hover {
    background-color: rgba(0,0,0,0.4) !important;
    color: #ffffff !important;
}
.duration-preset-selector .btn.duration-btn.active,
.duration-custom .btn.duration-btn.active {
    background-color: #e5e7eb !important;
    color: #111827 !important;
    border-color: #e5e7eb !important;
}
.setup-primary-card .duration-preset-selector .btn.duration-btn.active,
.setup-primary-card .duration-custom .btn.duration-btn.active {
    background-color: #e5e7eb !important;
    color: #111827 !important;
    border-color: #e5e7eb !important;
}
.freq-weekly-count input[type="number"],
.freq-monthly-count input[type="number"],
.freq-weekly-days input[type="number"],
.freq-monthly-days input[type="number"] {
    width: 60px; padding: 8px; text-align: center;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg);
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}
.setup-primary-card .freq-weekly-count input[type="number"],
.setup-primary-card .freq-monthly-count input[type="number"] {
    background-color: rgba(0,0,0,0.2);
    color: var(--bg);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Make input fields more visible in modals */
#settings-modal .freq-weekly-count input[type="number"],
#settings-modal .freq-monthly-count input[type="number"],
#settings-modal .freq-weekly-days input[type="number"],
#settings-modal .freq-monthly-days input[type="number"] {
    background-color: #f3f4f6;
    border: 2px solid #3b82f6;
    font-weight: 700;
}

/* Hide target input and text for simple habits */
.setting-item[data-habit-type="simple"] .target-inline-input-weekly-count,
.setting-item[data-habit-type="simple"] .target-inline-input-monthly-count,
.setting-item[data-habit-type="simple"] .target-inline-input-weekly-days,
.setting-item[data-habit-type="simple"] .target-inline-input-monthly-days,
.setting-item[data-habit-type="simple"] .target-inline-input-daily,
.setting-item[data-habit-type="simple"] .target-inline-input-weekly-count + span,
.setting-item[data-habit-type="simple"] .target-inline-input-monthly-count + span,
.setting-item[data-habit-type="simple"] .freq-weekly-days > div:last-child,
.setting-item[data-habit-type="simple"] .freq-monthly-days > div:nth-child(2),
.setup-primary-card[data-habit-type="simple"] .target-inline-input-weekly-count,
.setup-primary-card[data-habit-type="simple"] .target-inline-input-monthly-count,
.setup-primary-card[data-habit-type="simple"] .target-inline-input-weekly-days,
.setup-primary-card[data-habit-type="simple"] .target-inline-input-monthly-days,
.setup-primary-card[data-habit-type="simple"] .target-inline-input-daily,
.setup-primary-card[data-habit-type="simple"] .target-inline-input-weekly-count + span,
.setup-primary-card[data-habit-type="simple"] .target-inline-input-monthly-count + span,
.setup-primary-card[data-habit-type="simple"] .freq-weekly-days > div:last-child,
.setup-primary-card[data-habit-type="simple"] .freq-monthly-days > div:nth-child(2) {
    display: none !important;
}

/* Challenge Progress Container */
.challenge-progress-container {
    grid-column: 1 / -1;
    margin-bottom: 0;
    padding: 0 4px;
}

.challenge-progress-text {
    font-size: 14px;
    color: var(--muted);
    font-weight: 700;
    text-align: left;
    margin-top: 2px;
}

.dark-bg .challenge-progress-text {
    color: #9ca3af;
}

/* Habit Wrapper with dashed border */
.habit-wrapper {
    border: 1px dashed var(--muted);
    border-radius: 8px;
    padding: 8px;
    margin-bottom: 12px;
    background: #ffffff;
}

.dark-bg .habit-wrapper {
    border-color: #6b7280;
}

/* Darker background only for the 'Dein Habit Check' section */
#checkin.card {
    background: #f1f3f4;
}

.dark-bg #checkin.card {
    background: #374151;
}

/* Habit info text under buttons */
.habit-info-text {
    text-align: left;
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
    font-weight: 500;
}

/* Hide empty info text */
.habit-info-text:empty {
    display: none;
}

.dark-bg .habit-info-text {
    color: #9ca3af;
}

/* Unified button styles for completed states */
.btn-completed {
    background: var(--ok) !important;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(255, 255, 255, 0.4) 4px,
        rgba(255, 255, 255, 0.4) 8px
    ) !important;
    color: #ffffff !important;
    border: 2px solid var(--ok) !important;
    font-weight: bold !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3) !important;
}

.btn-bad.btn-completed {
    background: var(--bad) !important;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(255, 255, 255, 0.4) 4px,
        rgba(255, 255, 255, 0.4) 8px
    ) !important;
    color: #ffffff !important;
    border: 2px solid var(--bad) !important;
    font-weight: bold !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3) !important;
}

.btn-overlimit {
    background: repeating-linear-gradient(
        45deg,
        var(--bad),
        var(--bad) 10px,
        #ffffff 10px,
        #ffffff 20px
    ) !important;
    color: #ffffff !important;
    border: 1px solid var(--bad) !important;
}

.btn-counter {
    background-color: var(--ok) !important;
    color: #ffffff !important;
}

.btn-limit {
    background-color: var(--bad) !important;
    color: #ffffff !important;
}

/* Unified status block for completed habits */
.habit-status-block {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    text-align: center;
    font-weight: bold;
    color: #ffffff;
    border: 2px solid;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.habit-status-block.status-block-success {
    background: var(--ok);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(255, 255, 255, 0.3) 4px,
        rgba(255, 255, 255, 0.3) 8px
    );
    border-color: var(--ok);
}

.habit-status-block.status-block-failure {
    background: var(--bad);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 4px,
        rgba(255, 255, 255, 0.3) 4px,
        rgba(255, 255, 255, 0.3) 8px
    );
    border-color: var(--bad);
}

.habit-status-block.status-block-info {
    background: #ffffff;
    color: #333333;
    border-color: #dddddd;
    text-shadow: none;
}

/* Counter Progress Buttons */
.btn-counter-progress, .btn-limit-progress {
    position: relative;
    overflow: hidden;
    background: #ffffff;
    border: 2px solid #cccccc;
    color: #333333;
    min-height: 50px;
}

.counter-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress);
    background: var(--ok);
    transition: width 0.3s ease;
    z-index: 1;
}

.limit-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: var(--progress);
    background: var(--ok);
    transition: width 0.3s ease;
    z-index: 1;
}

.counter-progress-segments, .limit-progress-segments {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
}

.counter-progress-segments::before, .limit-progress-segments::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: repeating-linear-gradient(
        90deg,
        transparent,
        transparent calc(100% / var(--target) - 1px),
        #cccccc calc(100% / var(--target) - 1px),
        #cccccc calc(100% / var(--target))
    );
}

.counter-label, .limit-label {
    position: relative;
    z-index: 3;
    font-weight: bold;
    text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.8);
}

.btn-limit-progress.over-limit {
    background: #ffcccc;
    border-color: var(--bad);
}

.btn-limit-progress.over-limit .limit-progress-fill {
    background: var(--bad);
}

.btn-limit-progress.at-limit {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.btn-limit-progress.at-limit .limit-progress-fill {
    background: #ffc107;
}

/* Limit Zero Button - "Nicht getan" Button (Aktives Check-in System) */
.btn-limit-zero {
    background: linear-gradient(135deg, var(--ok) 0%, #15803d 100%);
    color: white;
    font-weight: 600;
    position: relative;
    overflow: hidden;
    border: 2px solid var(--ok);
    transition: all 0.2s ease;
}

.btn-limit-zero:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.btn-limit-zero:active {
    transform: scale(0.98);
}

/* Mutual Exclusivity - Disabled States für Limit-Buttons */
.btn-limit-zero.disabled,
.btn-limit-progress.disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
    filter: grayscale(50%);
}

/* Minimalistic Progress Bar */
.challenge-progress-bar {
    width: 100%;
    height: 8px;
    background-color: var(--bg);
    border: 1px solid var(--fg);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

.challenge-progress-fill {
    height: 100%;
    background-color: var(--fg);
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        rgba(255, 255, 255, 0.2) 2px,
        rgba(255, 255, 255, 0.2) 4px
    );
    transition: width 0.3s ease-in-out;
    border-radius: 2px;
}

.dark-bg .challenge-progress-bar {
    background-color: var(--dark-bg);
    border-color: #d1d5db;
}

.dark-bg .challenge-progress-fill {
    background-color: #d1d5db;
    background-image: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 2px,
        rgba(0, 0, 0, 0.2) 2px,
        rgba(0, 0, 0, 0.2) 4px
    );
}

/* Icon Picker Styles */
.icon-picker-container {
    position: relative;
    margin: 8px 0;
    width: fit-content;
}

.icon-preview-compact {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: var(--bg);
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 60px;
    height: 50px;
    box-sizing: border-box;
}

.icon-preview-compact:hover {
    background-color: #f8f9fa;
}

.icon-preview-svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    filter: none;
}

.icon-preview-compact .dropdown-arrow {
    font-size: 12px;
    color: var(--muted);
    position: absolute;
    bottom: 2px;
    right: 4px;
}

.dropdown-arrow {
    font-size: 14px;
    color: var(--muted);
    flex-shrink: 0;
}

.icon-grid {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background-color: #f8f9fa;
    margin-top: 8px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    padding: 12px;
}

.icon-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    border-radius: 4px;
    background-color: var(--bg);
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    aspect-ratio: 1;
}

.icon-option:hover {
    background-color: var(--fg);
    border-color: var(--fg);
    transform: scale(1.05);
}

.icon-svg {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: none;
}

.icon-option:hover .icon-svg {
    filter: brightness(0) invert(1);
}

.icon-category-section {
    margin-bottom: 20px;
}

.icon-category-section:last-child {
    margin-bottom: 0;
}

.icon-category-header {
    margin: 0 0 10px 0;
    padding: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--fg);
}

.icon-category-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
}

@media (max-width: 600px) {
    .icon-category-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: 6px;
    }

    .icon-option {
        padding: 8px;
    }

    .icon-svg {
        width: 20px;
        height: 20px;
    }

    .icon-category-header {
        font-size: 13px;
    }
}

/* Deleted Habit Icon - Diagonal Strikethrough */
.habit-icon-deleted {
    position: relative;
    display: inline-block;
}

.habit-icon-deleted::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        to bottom right,
        transparent calc(50% - 1.5px),
        var(--bad) calc(50% - 1.5px),
        var(--bad) calc(50% + 1.5px),
        transparent calc(50% + 1.5px)
    );
    pointer-events: none;
    z-index: 10;
}

/* Statistics Modal Styles */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    text-align: left;
}

.stat-box {
    background-color: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--fg);
}

@media (max-width: 600px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================================
   STATISTICS CARD STYLES
   ============================================================================ */

/* Header (Global Metrics) */
.statistics-header {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.statistics-header-metric {
    text-align: center;
}

.statistics-header-label {
    display: block;
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.statistics-header-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--fg);
    cursor: help;
}

.streak-update-hint {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: none;
    letter-spacing: normal;
}

/* Title Countdown - Monochrom and left-aligned */
.statistics-title-countdown {
    color: var(--fg);
    padding: 0;
    border-radius: 0;
    font-size: 1.5rem;
    font-weight: 900;
    text-align: left;
    letter-spacing: 0;
    white-space: nowrap;
    animation: pulse-countdown-mono 2s ease-in-out infinite;
}

@keyframes pulse-countdown-mono {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@media (max-width: 600px) {
    .statistics-title-countdown {
        font-size: 1.2rem;
    }
}

/* Table Container */
.statistics-table-container {
    margin-bottom: 32px;
    overflow-x: auto;
}

.statistics-table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--bg);
}

.statistics-table thead {
    background-color: #f8f9fa;
}

.statistics-table th {
    padding: 12px 16px;
    text-align: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--fg);
    border-bottom: 2px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.statistics-table th:first-child {
    text-align: left;
    width: 120px;
}

.statistics-table tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.statistics-table tbody tr:hover {
    background-color: #f8f9fa;
}

.statistics-table tbody tr:last-child {
    border-bottom: none;
}

.statistics-table td {
    padding: 14px 16px;
    text-align: center;
    font-size: 0.95rem;
}

.statistics-table td:first-child {
    text-align: left;
    font-weight: 700;
    color: var(--fg);
}

.statistics-table td .subvalue {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 600;
    margin-left: 4px;
}

/* Sections */
.statistics-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.statistics-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.statistics-section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--fg);
}

/* Weekday Performance */
.statistics-weekday-info-notice {
    background-color: #fef3c7;
    color: #92400e;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
}

.statistics-weekday-bars {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.statistics-weekday-bar-wrapper {
    display: grid;
    grid-template-columns: 40px 1fr 60px;
    align-items: center;
    gap: 12px;
}

.statistics-weekday-label {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--fg);
    text-align: left;
}

.statistics-weekday-bar {
    height: 24px;
    background-color: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
    position: relative;
    border: 2px solid transparent;
    transition: border-color 0.2s ease;
}

.statistics-weekday-bar.best {
    border-color: var(--ok);
}

.statistics-weekday-bar.worst {
    border-color: #f59e0b;
}

.statistics-weekday-fill {
    height: 100%;
    background-color: var(--ok);
    transition: width 0.3s ease;
}

.statistics-weekday-percent {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--fg);
    text-align: right;
}

.statistics-weekday-summary {
    font-size: 0.9rem;
    color: var(--muted);
    text-align: center;
    margin-top: 12px;
    font-weight: 600;
}

/* Challenges */
.statistics-challenges-medals {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    justify-content: center;
    margin-bottom: 12px;
}

.statistics-medal {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background-color: #f8f9fa;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.statistics-challenges-summary {
    font-size: 0.9rem;
    color: var(--muted);
    text-align: center;
    font-weight: 600;
}

/* Perfect Days - Color-coded */
.perfect-days-green {
    color: var(--ok);
    font-weight: 700;
}

.perfect-days-yellow {
    color: #f59e0b;
    font-weight: 700;
}

.perfect-days-gray {
    color: var(--muted);
    font-weight: 700;
}

/* Trend Arrows */
.trend-up {
    color: var(--ok);
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 6px;
}

.trend-down {
    color: var(--bad);
    font-size: 0.85rem;
    font-weight: 600;
    margin-left: 6px;
}

/* Missed Chip */
.missed-chip {
    font-size: 0.9rem;
    color: var(--muted);
    font-weight: 600;
}

/* Low Data Badge */
.low-data-badge {
    display: inline-block;
    background-color: #fef3c7;
    color: #92400e;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: help;
}

/* Responsive */
@media (max-width: 900px) {
    .statistics-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .statistics-header {
        grid-template-columns: 1fr;
    }

    .statistics-header-value {
        font-size: 1.2rem;
    }

    .statistics-kpi-grid {
        grid-template-columns: 1fr;
    }

    .statistics-kpi-value {
        font-size: 1.5rem;
    }

    .statistics-weekday-bar-wrapper {
        grid-template-columns: 35px 1fr 50px;
        gap: 8px;
    }

    .statistics-weekday-label {
        font-size: 0.8rem;
    }

    .statistics-weekday-percent {
        font-size: 0.8rem;
    }
}

/* ============================================
   REVIEW SECTION (TABS: ACHIEVEMENTS + HISTORY)
   ============================================ */

/* Review Header */
.review-header {
    margin-bottom: 20px;
}

/* Tab Navigation */
.review-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 25px;
}

/* Individual Tab Button */
.review-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 12px 24px;
    margin-bottom: -2px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.review-tab:hover {
    color: var(--fg);
    background-color: #f9fafb;
}

.review-tab.active {
    color: var(--fg);
    border-bottom-color: var(--fg);
    font-weight: 700;
}

/* Tab Content Panels */
.review-tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.review-tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   PROGRESS SECTION (TABS: STADTFEST + KALENDER)
   ============================================ */

/* Progress Header */
.progress-header {
    margin-bottom: 20px;
}

/* Tab Navigation */
.progress-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 25px;
}

/* Individual Tab Button */
.progress-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 12px 24px;
    margin-bottom: -2px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.progress-tab:hover {
    color: var(--fg);
    background-color: #f9fafb;
}

.progress-tab.active {
    color: var(--fg);
    border-bottom-color: var(--fg);
    font-weight: 700;
}

/* Tab Content Panels */
.progress-tab-content {
    display: none;
    animation: fadeIn 0.2s ease;
}

.progress-tab-content.active {
    display: block;
}

/* ============================================
   HISTORY PANEL STYLES
   ============================================ */

/* History Tags Container */
.history-tags-container {
    margin-bottom: 30px;
}

.history-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 15px;
}

/* Individual Tag */
.history-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background-color: var(--bg);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--fg);
    user-select: none;
}

.history-tag:hover {
    border-color: var(--muted);
    background-color: #f9fafb;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.history-tag.selected {
    background-color: var(--fg);
    color: var(--bg);
    border-color: var(--fg);
}

.history-tag.selected:hover {
    background-color: #374151;
    border-color: #374151;
}

.history-tag.deleted {
    opacity: 0.6;
}

.history-tag.deleted .history-tag-name {
    text-decoration: line-through;
}

.history-tag img {
    filter: grayscale(0);
    transition: filter 0.2s ease;
}

.history-tag:not(.selected) img {
    filter: grayscale(60%);
}

/* History Reports Container */
.history-reports-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.history-empty-reports {
    text-align: center;
    padding: 40px;
    color: var(--muted);
    font-size: 1rem;
    grid-column: 1 / -1;
}

/* Report Card */
.history-report-card {
    background-color: var(--bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
}

.history-report-card:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Report Header */
.history-report-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.history-report-title {
    flex: 1;
}

.history-report-title h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fg);
}

.history-report-status {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.history-report-status.active {
    background-color: #dcfce7;
    color: #166534;
}

.history-report-status.completed_challenge {
    background-color: #dbeafe;
    color: #1e40af;
}

.history-report-status.deleted {
    background-color: #f3f4f6;
    color: #6b7280;
}

/* Report Body */
.history-report-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-report-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
}

.history-report-label {
    font-size: 0.85rem;
    color: var(--muted);
    font-weight: 600;
}

.history-report-value {
    font-size: 0.9rem;
    color: var(--fg);
    font-weight: 600;
    text-align: right;
}

/* Pagination */
.history-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

#history-page-info {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    min-width: 120px;
    text-align: center;
}

/* Responsive */
@media (max-width: 768px) {
    .history-reports-container {
        grid-template-columns: 1fr;
    }

    .history-tag {
        font-size: 0.85rem;
        padding: 6px 12px;
    }

    .history-report-card {
        padding: 16px;
    }

    .history-report-header {
        flex-direction: row;
        align-items: flex-start;
    }
}

/* ==================== MOBILE BOTTOM NAVIGATION ==================== */

/* Hide Bottom Nav on Desktop */
.bottom-nav {
    display: none;
}

/* Hide internal tabs and header on mobile (Stadtfest/Kalender use bottom nav instead) */
@media (max-width: 768px) {
    .progress-tabs {
        display: none !important;
    }

    .progress-header {
        display: none !important;
    }

    /* Hide footer on mobile (links are in hamburger menu) */
    .page-footer {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--bg);
        border-top: 1px solid var(--border-color);
        padding: 8px 0;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        justify-content: space-around;
        align-items: center;
        z-index: 1000;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    .bottom-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        padding: 6px 12px;
        cursor: pointer;
        transition: all 0.2s ease;
        color: var(--muted);
        flex: 1;
        max-width: 80px;
    }

    .bottom-nav-item.active {
        color: var(--fg);
    }

    .bottom-nav-icon {
        width: 24px;
        height: 24px;
        margin-bottom: 4px;
        stroke: currentColor;
    }

    .bottom-nav-label {
        font-size: 0.7rem;
        font-weight: 600;
        text-align: center;
        line-height: 1.2;
    }

    /* Add padding to bottom of content to prevent overlap with bottom nav */
    .container {
        padding-bottom: calc(70px + env(safe-area-inset-bottom));
    }

    /* On mobile: hide all main sections by default - switchMobileTab() will show the active one */
    #setup,
    #simulate-section,
    #checkin,
    #focus,
    #progress-card,
    #statistics-card,
    #review-card,
    #danger {
        display: none;
    }
}

/* ==================== HAMBURGER MENU ==================== */

/* Default: Hide hamburger button (will be shown in media queries) */
.hamburger-btn {
    display: none;
}

/* Hide Hamburger Menu Overlay by default */
.hamburger-menu {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1002;
    animation: fadeIn 0.2s ease;
}

.hamburger-menu.active {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.hamburger-menu-header {
    background: var(--bg);
    width: 80%;
    max-width: 300px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    animation: slideInLeft 0.3s ease;
}

.hamburger-menu-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--fg);
}

.hamburger-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
}

.hamburger-close svg {
    width: 20px;
    height: 20px;
    stroke: var(--fg);
}

.hamburger-menu-content {
    background: var(--bg);
    width: 80%;
    max-width: 300px;
    flex: 1;
    padding: 10px 0;
    overflow-y: auto;
    animation: slideInLeft 0.3s ease;
}

.hamburger-menu-item {
    display: flex;
    align-items: center;
    gap: 16px;
    width: 100%;
    background: none;
    border: none;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-size: 1rem;
    color: var(--fg);
    text-align: left;
    text-decoration: none;
}

.hamburger-menu-item:hover,
.hamburger-menu-item:active {
    background: var(--border-color);
}

.hamburger-menu-item svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
    flex-shrink: 0;
}

.hamburger-menu-item.danger {
    color: var(--bad);
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
    }
    to {
        transform: translateX(0);
    }
}

@media (max-width: 768px) {
    .hamburger-btn {
        display: flex;
        position: fixed;
        top: 16px;
        left: 16px;
        width: 44px;
        height: 44px;
        background: var(--bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 1001;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
    }

    .hamburger-btn:active {
        transform: scale(0.95);
    }

    .hamburger-btn svg {
        width: 24px;
        height: 24px;
        stroke: var(--fg);
    }

    .hamburger-menu {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1002;
        animation: fadeIn 0.2s ease;
    }

    .hamburger-menu.active {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .hamburger-menu-header {
        background: var(--bg);
        width: 80%;
        max-width: 300px;
        padding: 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        border-bottom: 1px solid var(--border-color);
        animation: slideInLeft 0.3s ease;
    }

    .hamburger-menu-header h3 {
        margin: 0;
        font-size: 1.2rem;
        color: var(--fg);
    }

    .hamburger-close {
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px;
    }

    .hamburger-close svg {
        width: 20px;
        height: 20px;
        stroke: var(--fg);
    }

    .hamburger-menu-content {
        background: var(--bg);
        width: 80%;
        max-width: 300px;
        flex: 1;
        padding: 10px 0;
        overflow-y: auto;
        animation: slideInLeft 0.3s ease;
    }

    .hamburger-menu-item {
        display: flex;
        align-items: center;
        gap: 16px;
        width: 100%;
        background: none;
        border: none;
        padding: 16px 20px;
        cursor: pointer;
        transition: background 0.2s ease;
        font-size: 1rem;
        color: var(--fg);
        text-align: left;
    }

    .hamburger-menu-item:hover,
    .hamburger-menu-item:active {
        background: var(--border-color);
    }

    .hamburger-menu-item svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
        flex-shrink: 0;
    }

    .hamburger-menu-item.danger {
        color: var(--bad);
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
        }
        to {
            opacity: 1;
        }
    }

    @keyframes slideInLeft {
        from {
            transform: translateX(-100%);
        }
        to {
            transform: translateX(0);
        }
    }
}

/* ========================================
   TUTORIAL SYSTEM
   ======================================== */

.tutorial-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
}

.tutorial-container {
    width: 100%;
    max-width: 800px;
    background: var(--bg);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.tutorial-step {
    display: none;
    animation: tutorialFadeIn 0.4s ease;
}

.tutorial-step.active {
    display: block !important;
}

@keyframes tutorialFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.tutorial-header {
    text-align: center;
    margin-bottom: 30px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 20px;
}

.tutorial-header h1 {
    font-size: 2rem;
    font-weight: 900;
    color: var(--fg);
    margin: 0 0 10px 0;
}

.tutorial-header h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--fg);
    margin: 0;
}

.tutorial-header p {
    color: var(--muted);
    font-size: 1rem;
    margin: 10px 0 0 0;
}

.tutorial-content {
    margin: 30px 0;
    min-height: 250px;
}

.tutorial-text {
    color: var(--fg);
    line-height: 1.8;
    font-size: 1.05rem;
    margin-bottom: 20px;
}

.tutorial-text strong {
    font-weight: 700;
    color: var(--fg);
}

/* Half Progress Ring (0-40) */
.progress-ring-demo {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 40px 0;
}

.progress-ring-half {
    position: relative;
    width: 200px;
    height: 120px;
    overflow: hidden;
}

.progress-ring-half svg {
    width: 200px;
    height: 200px;
}

.progress-ring-circle {
    transition: stroke-dashoffset 0.8s ease, stroke 0.3s ease;
    fill: transparent;
    stroke-linecap: round;
    stroke-width: 14;
}

.progress-ring-bg {
    stroke: var(--miss);
    stroke-width: 14;
    fill: transparent;
}

.progress-ring-text {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    font-weight: 900;
    font-size: 2.5rem;
    color: var(--fg);
    text-align: center;
}

.progress-ring-label {
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 5px;
    font-weight: 700;
}

/* Points Display */
.points-demo {
    text-align: center;
    margin: 40px 0;
}

.points-value {
    font-size: 4rem;
    font-weight: 900;
    margin: 20px 0;
    animation: pointsPop 0.6s ease;
}

.points-value.positive {
    color: var(--ok);
}

.points-value.negative {
    color: var(--bad);
}

.points-value.neutral {
    color: var(--muted);
}

@keyframes pointsPop {
    0% { transform: scale(0); opacity: 0; }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.points-explanation {
    color: var(--muted);
    font-size: 1rem;
    font-weight: 600;
}

/* Habit Examples */
.habit-examples {
    display: grid;
    gap: 15px;
    margin: 30px 0;
}

.habit-example {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    background: var(--bg);
}

.habit-example h3 {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    color: var(--fg);
}

.habit-example p {
    margin: 5px 0;
    color: var(--muted);
    font-size: 0.95rem;
}

.habit-example .example-visual {
    margin-top: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 6px;
    font-weight: 600;
    text-align: center;
}

/* Presets Grid */
.presets-demo {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 30px 0;
}

.preset-item {
    background: var(--muted);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 700;
    text-align: left;
}

.preset-item strong {
    display: block;
    font-size: 1rem;
    margin-bottom: 5px;
}

.preset-item small {
    font-size: 0.75rem;
    opacity: 0.8;
}

/* Challenge Badge */
.challenge-badge {
    border: 3px solid #daa520;
    box-shadow: 0 4px 16px rgba(218, 165, 32, 0.3);
    background: linear-gradient(135deg, rgba(255, 255, 255, 1) 0%, rgba(255, 250, 220, 0.7) 100%);
    padding: 20px;
    border-radius: 12px;
    margin: 30px 0;
    text-align: center;
}

.challenge-badge h3 {
    margin: 0 0 10px 0;
    color: #b8860b;
    font-size: 1.3rem;
}

.challenge-badge p {
    margin: 5px 0;
    color: var(--fg);
}

/* Playground Images */
.playground-images {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin: 30px 0;
}

.playground-image-item {
    text-align: center;
}

.playground-image-item img {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    aspect-ratio: 1;
    object-fit: cover;
}

.playground-image-item p {
    margin: 10px 0 0 0;
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--muted);
}

/* Calendar Demo */
.calendar-demo {
    margin: 30px 0;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 5px;
}

.weekday {
    font-weight: 700;
    text-align: center;
    color: var(--muted);
    font-size: 0.8rem;
    padding-bottom: 10px;
}

.calendar-day {
    min-height: 70px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    background: var(--bg);
}

.day-number {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--fg);
    padding: 2px;
}

.day-segments {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 4px;
    height: auto;
    margin-top: auto;
}

.seg {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.seg img {
    width: 16px;
    height: 16px;
    object-fit: contain;
    filter: brightness(0) invert(1);
}

.legend-row {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--muted);
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
}

/* Achievements */
.achievements-demo {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin: 30px 0;
}

.achievement-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    background: var(--bg);
}

.achievement-medal {
    font-size: 3rem;
    margin-bottom: 10px;
}

.achievement-item h4 {
    margin: 0 0 5px 0;
    font-size: 1rem;
    color: var(--fg);
}

.achievement-item p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted);
}

/* Tutorial Navigation */
.tutorial-navigation {
    display: flex;
    gap: 12px;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.tutorial-navigation .btn {
    flex: 1;
    font-weight: 900;
    font-size: 1.5rem;
    line-height: 1;
}

/* Progress Indicator */
.progress-indicator {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border-color);
    transition: all 0.3s ease;
}

.progress-dot.active {
    background: var(--fg);
    transform: scale(1.5);
}

/* Info Box */
.info-box {
    background: #f8f9fa;
    border-left: 4px solid var(--fg);
    padding: 15px 20px;
    margin: 20px 0;
    border-radius: 4px;
}

.info-box p {
    margin: 0;
    color: var(--fg);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Metric Card Demo */
.metric-card-demo {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    background-color: var(--bg);
    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    margin: 30px 0;
}

/* Responsive */
@media (max-width: 600px) {
    .tutorial-container {
        padding: 30px 20px;
    }

    .tutorial-header h1 {
        font-size: 1.5rem;
    }

    .tutorial-header h2 {
        font-size: 1.2rem;
    }

    .playground-images {
        grid-template-columns: 1fr;
    }

    .points-value {
        font-size: 3rem;
    }

    .metric-card-demo {
        flex-direction: column;
        padding: 24px;
    }

    .tutorial-navigation {
        flex-wrap: wrap;
    }

    .tutorial-navigation .btn {
        min-width: 100px;
    }
}

/* =======================================
   ANIMATION: ENERGY FLOW CARD
   ======================================== */
@property --angle {
  syntax: '<angle>';
  initial-value: 0deg;
  inherits: false;
}

@keyframes energy-flow {
  to {
    --angle: 360deg;
  }
}

/* =======================================
   REFINED POWER GAUGE
   ======================================== */

.gauge-progress-path {
    /* The glow color will be the same as the stroke color */
    filter: drop-shadow(0 2px 4px var(--glow-color));
    transition: stroke-dashoffset 0.8s cubic-bezier(0.65, 0, 0.35, 1), 
                stroke 0.5s ease, 
                filter 0.5s ease;
}

.gauge-notch {
    transition: fill 0.4s ease;
}

.gauge-notch.active {
    fill: var(--glow-color);
}

/* Class for the animated counter text */
.gauge-value-animating {
    transition: none; /* Disable transition during fast counting */
}

/* =======================================
   PULSING BUTTON ANIMATION
   ======================================== */

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }
    50% {
        transform: scale(1.04);
        box-shadow: 0 6px 12px rgba(0,0,0,0.15);
    }
}

.pulse-alternate-1 {
    animation: pulse 3s ease-in-out infinite;
}

.pulse-alternate-2 {
    animation: pulse 3s ease-in-out infinite;
    animation-delay: 1.5s;
}


/* Animation for when a streak increases */
@keyframes streakUp {
    0% {
        transform: scale(1);
        text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
    }
    50% {
        transform: scale(1.4);
        text-shadow: 0 0 16px rgba(255, 255, 255, 1);
    }
    100% {
        transform: scale(1);
        text-shadow: 0 0 4px rgba(255, 255, 255, 0.5);
    }
}

.streak-up-animation {
    animation: streakUp 0.6s ease-in-out;
}

/* Animation for when a streak drops to zero */
@keyframes streakZero {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
    0%, 50%, 100% {
        box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    }
    25%, 75% {
        box-shadow: 0 0 20px 5px rgba(239, 68, 68, 0.7);
    }
}

.streak-zero-animation {
    animation: streakZero 0.8s cubic-bezier(.36,.07,.19,.97) both;
    border-color: var(--bad);
}

/* ============================================================================
   STATISTICS TAB SYSTEM
   ============================================================================ */

.statistics-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 0;
}

.statistics-tab {
    background: transparent;
    border: none;
    padding: 12px 24px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
}

.statistics-tab:hover {
    color: var(--fg);
    background: rgba(139, 92, 246, 0.05);
}

.statistics-tab.active {
    color: #8b5cf6;
    border-bottom-color: #8b5cf6;
}

.statistics-tab-content {
    display: none;
}

.statistics-tab-content.active {
    display: block;
}

/* ============================================================================
   CHART VISUALIZATION STYLES (New Statistics Chart View)
   ============================================================================ */

.statistics-chart-section {
    margin-bottom: 30px;
    background: var(--bg);
    border-radius: 12px;
    overflow: hidden;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.chart-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    color: var(--fg);
}

.chart-average {
    font-size: 1rem;
    color: var(--muted);
}

#chart-average-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fg);
}

.chart-date-range {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 15px;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 280px;
    margin-bottom: 20px;
    background: var(--bg);
}

/* Grid should have same height as chart to prevent layout shift */
.chart-365-grid {
    position: relative;
    min-height: 280px; /* Match chart height exactly */
    margin-bottom: 20px; /* Match chart margin */
    overflow-y: auto; /* Allow scrolling if needed */
}

.chart-period-toggles {
    display: flex;
    gap: 8px;
    justify-content: center;
    background: var(--bg-secondary, #f3f4f6);
    padding: 6px;
    border-radius: 24px;
    width: fit-content;
    margin: 20px auto 0 auto;
}

.chart-period-btn {
    background: transparent;
    border: none;
    padding: 8px 16px;
    border-radius: 18px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-period-btn:hover {
    color: var(--fg);
    background: rgba(139, 92, 246, 0.1);
}

.chart-period-btn.active {
    background: #8b5cf6;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.chart-period-btn svg {
    opacity: 0.8;
}

.chart-period-btn.active svg {
    opacity: 1;
}

/* 365 Days Grid View (GitHub-style) - additional styles */
.chart-365-grid {
    padding: 20px;
    background: var(--bg);
    border-radius: 8px;
}

.grid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.grid-days-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--fg);
}

.grid-date-range {
    font-size: 0.85rem;
    color: var(--muted);
}

.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(14px, 1fr)); /* Many small columns, auto-layout */
    gap: 4px;
    padding: 12px 0;
    max-width: 100%;
}

.grid-day {
    width: 100%;
    aspect-ratio: 1; /* Keep circles */
    max-width: 14px; /* Small circles like 30D habit view */
    max-height: 14px;
    border-radius: 50%; /* CIRCLES not squares */
    background: var(--border-color);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.grid-day:hover {
    transform: scale(1.3);
    z-index: 10;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Success rate colors for grid */
.grid-day.rate-0 {
    background: var(--bad);
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.3);
}

.grid-day.rate-25 {
    background: rgba(139, 92, 246, 0.3);
    box-shadow: 0 1px 3px rgba(139, 92, 246, 0.2);
}

.grid-day.rate-50 {
    background: rgba(139, 92, 246, 0.5);
    box-shadow: 0 1px 3px rgba(139, 92, 246, 0.3);
}

.grid-day.rate-75 {
    background: rgba(139, 92, 246, 0.7);
    box-shadow: 0 1px 3px rgba(139, 92, 246, 0.4);
}

.grid-day.rate-100 {
    background: #8b5cf6;
    box-shadow: 0 2px 4px rgba(139, 92, 246, 0.5);
}

.grid-day.empty {
    background: transparent;
    border: 1px solid var(--border-color);
    box-shadow: none;
}

/* Tooltip for grid day */
.grid-day-tooltip {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.75rem;
    white-space: nowrap;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.grid-day:hover .grid-day-tooltip {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chart-container {
        height: 220px;
    }

    .chart-title {
        font-size: 1.2rem;
    }

    .chart-period-toggles {
        gap: 4px;
        padding: 4px;
    }

    .chart-period-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
        min-width: 44px;
    }

    .grid-container {
        gap: 3px;
        grid-template-columns: repeat(auto-fill, minmax(12px, 1fr));
    }

    .grid-day {
        max-width: 12px; /* Smaller on mobile */
        max-height: 12px;
    }

    .chart-365-grid {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .chart-container {
        height: 180px;
    }

    .grid-day {
        max-width: 10px; /* Even smaller on small mobile */
        max-height: 10px;
    }

    .grid-container {
        gap: 2px;
        grid-template-columns: repeat(auto-fill, minmax(10px, 1fr));
    }
}

/* ============================================================================
   HABIT CARDS (Tab 2 & 3)
   ============================================================================ */

#habits-cards-container,
#history-cards-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.habit-card {
    background: var(--bg-secondary, #f3f4f6);
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.habit-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.habit-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.habit-card-icon {
    width: 48px;
    height: 48px;
    min-width: 48px;
    min-height: 48px;
    border-radius: 50%;
    background: rgba(139, 92, 246, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.habit-card-icon img,
.habit-card-icon svg {
    width: 28px;
    height: 28px;
    min-width: 28px;
    min-height: 28px;
    opacity: 0.9;
    display: block;
    object-fit: contain;
}

.habit-card-icon svg {
    color: #8b5cf6;
}

.habit-card-info {
    flex: 1;
}

.habit-card-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--fg);
    margin: 0 0 4px 0;
}

.habit-card-stats {
    font-size: 0.85rem;
    color: var(--muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.habit-card-stat {
    display: inline-block;
}

.habit-card-toggle {
    display: flex;
    gap: 6px;
    background: var(--bg);
    padding: 4px;
    border-radius: 16px;
    margin-top: 16px;
    justify-content: center;
}

.habit-card-toggle-btn {
    background: transparent;
    border: none;
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.habit-card-toggle-btn:hover {
    color: var(--fg);
}

.habit-card-toggle-btn.active {
    background: #8b5cf6;
    color: #ffffff;
}

.habit-card-delete-btn {
    background: transparent;
    border: none;
    padding: 8px;
    margin-left: 8px;
    border-radius: 8px;
    color: var(--danger, #ef4444);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.habit-card-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    transform: scale(1.1);
}

.habit-card-delete-btn svg {
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.habit-card-viz {
    margin-top: 16px;
    min-height: 180px;
}

/* 7D Bars Visualization */
.habit-7d-bars {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 180px;
    gap: 8px;
    padding: 0 12px;
}

.habit-7d-bar-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.habit-7d-bar {
    width: 100%;
    background: var(--miss);
    border-radius: 6px 6px 0 0;
    transition: height 0.8s cubic-bezier(0.34, 1.56, 0.64, 1), background 0.3s ease;
    position: relative;
    min-height: 8px;
    height: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.habit-7d-bar.success {
    background: linear-gradient(to top, #16a34a, #22c55e);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

.habit-7d-bar.failed {
    background: linear-gradient(to top, #dc2626, #ef4444);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.2);
}

.habit-7d-bar.empty {
    background: transparent;
    border: 1px dashed var(--border-color);
    box-shadow: none;
    min-height: 0;
}

.habit-7d-bar-label {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
}

/* 30D Grid Visualization */
.habit-30d-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    padding: 12px;
    max-width: 280px;
    margin: 0 auto;
}

.habit-30d-dot {
    width: 100%;
    max-width: 28px;
    aspect-ratio: 1;
    border-radius: 50%;
    background: var(--miss);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
    transform: scale(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.habit-30d-dot.animate {
    opacity: 1;
    transform: scale(1);
}

.habit-30d-dot.success {
    background: #22c55e;
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.4);
}

.habit-30d-dot.failed {
    background: var(--bad);
    box-shadow: 0 2px 6px rgba(239, 68, 68, 0.3);
}

.habit-30d-dot.empty {
    background: transparent;
    border: 1px solid var(--border-color);
    box-shadow: none;
}

/* 365D Grid Visualization for Habit Cards */
.habit-365-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(10px, 1fr));
    gap: 3px;
    padding: 12px 0;
    max-width: 100%;
    max-height: 180px;
    overflow-y: auto;
}

.habit-365-dot {
    width: 100%;
    aspect-ratio: 1;
    max-width: 10px;
    max-height: 10px;
    border-radius: 50%;
    background: var(--border-color);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.habit-365-dot.success {
    background: #22c55e;
    box-shadow: 0 1px 3px rgba(34, 197, 94, 0.4);
}

.habit-365-dot.failed {
    background: var(--bad);
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.3);
}

.habit-365-dot.missed {
    background: var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 2px solid #000;
}

.habit-365-dot.empty {
    background: var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.habit-365-dot:hover {
    transform: scale(1.3);
    z-index: 10;
}

/* Animations */
@keyframes barGrowUp {
    from {
        height: 0;
    }
    to {
        height: var(--bar-height);
    }
}

@keyframes dotPopIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    /* Keep horizontal layout on tablets */
    .habit-card-toggle {
        flex-wrap: wrap;
    }

    .habit-card-toggle-btn {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .habit-7d-bars {
        gap: 4px;
        padding: 0 8px;
        height: 150px;
    }

    .habit-30d-grid {
        gap: 4px;
        max-width: 240px;
    }

    .habit-30d-dot {
        max-width: 24px;
    }

    .habit-card-viz {
        min-height: 150px;
        max-width: 100%;
        overflow-x: hidden;
    }

    .habit-365-grid {
        max-width: 100%;
        overflow-x: hidden;
    }
}

@media (max-width: 600px) {
    /* Use full width on mobile */
    .container {
        padding: 8px 8px calc(80px + env(safe-area-inset-bottom)) 8px;
    }

    .card {
        padding: 12px;
        margin-bottom: 12px;
        border-radius: 8px;
    }

    /* Keep habit card header horizontal and compact */
    .habit-card-header {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        margin-bottom: 12px;
    }

    .habit-card-header .habit-name-header {
        flex: 1;
        font-size: 0.95rem;
    }

    .habit-card-header button {
        flex-shrink: 0;
        padding: 6px;
        margin-left: 0;
    }

    /* Ensure edit and delete buttons stay on the right */
    .habit-card-header button:first-of-type {
        margin-left: auto;
    }

    .habit-card-header img {
        width: 24px;
        height: 24px;
        flex-shrink: 0;
    }

    /* Compact metric displays */
    .current-streak-number {
        font-size: 48px;
    }

    .cell-streak {
        font-size: 36px;
    }

    .metric-label {
        font-size: 0.7rem;
    }

    .habit-card-toggle {
        flex-wrap: wrap;
        gap: 4px;
        width: 100%;
        justify-content: center;
    }

    .habit-card-toggle-btn {
        padding: 5px 8px;
        font-size: 0.75rem;
        flex: 0 0 auto;
    }

    .habit-card-viz {
        overflow-x: hidden;
    }

    .chart-container,
    .chart-365-grid {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Make statistics header compact like in image 51.jpg */
    .statistics-header {
        max-width: 100%;
        overflow-x: hidden;
        gap: 6px;
        grid-template-columns: repeat(3, 1fr);
        padding: 8px 0;
        margin-bottom: 16px;
        background: transparent;
        border: none;
    }

    .statistics-header-metric {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
    }

    .statistics-header-label {
        font-size: 0.6rem;
        text-align: center;
        line-height: 1.1;
        margin-bottom: 2px;
    }

    .statistics-header-value {
        font-size: 1.3rem;
        font-weight: 700;
        text-align: center;
    }

    /* Hide "Tage" text on mobile to save space */
    .statistics-header-value .days-label {
        display: none;
    }

    .habit-card-stats {
        flex-wrap: wrap;
        font-size: 0.75rem;
        gap: 8px;
    }

    /* Statistics tabs - make them smaller and fit */
    .statistics-tabs {
        gap: 4px;
        justify-content: space-between;
        margin-bottom: 16px;
    }

    .statistics-tab {
        padding: 10px 8px;
        font-size: 0.8rem;
        flex: 1;
        min-width: 0;
    }

    /* Change "Rückblicke" to "Erfolge" on mobile */
    .bottom-nav-item[data-tab="rueckblicke"] .bottom-nav-label {
        font-size: 0;
    }

    .bottom-nav-item[data-tab="rueckblicke"] .bottom-nav-label::after {
        content: "Erfolge";
        font-size: 0.7rem;
    }
}

/* ==========================================
   SPLASH SCREEN (Loading Screen)
   ========================================== */

#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    z-index: 99999;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: opacity 0.5s ease-out;
}

#splash-screen.fade-out {
    opacity: 0;
    pointer-events: none;
}

/* Splash Image - Fullscreen Cover */
.splash-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* Loader Container - positioned below the "powerhabit" text */
.splash-loader-container {
    position: absolute;
    bottom: 61%; /* Optimale Position unter "POWERHABIT" */
    left: 50%;
    transform: translateX(-50%);
    width: 72%; /* Exakte Breite passend zur "POWERHABIT" Typografie */
    max-width: 600px;
    z-index: 2;
}

/* Pixelart Loader Background (empty bar) */
.splash-loader-bg {
    width: 100%;
    height: 16px; /* Pixelart style - chunky height */
    background: rgba(0, 0, 0, 0.3);
    border: 3px solid rgba(255, 255, 255, 0.4);
    border-radius: 0; /* No border-radius for pixelart */
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.4),
        0 2px 8px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
    image-rendering: pixelated; /* Pixelart style */
    image-rendering: -moz-crisp-edges;
    image-rendering: crisp-edges;
}

/* Pixelart Loader Fill (animated progress) */
.splash-loader-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%; /* Starts at 0, will be animated via JS */
    background: linear-gradient(90deg,
        #80e908 0%,
        #a0ff20 50%,
        #80e908 100%
    );
    transition: width 0.3s ease-out;
    box-shadow:
        0 0 10px rgba(128, 233, 8, 0.6),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
}

/* Pixelart style segments (optional visual enhancement) */
.splash-loader-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        90deg,
        transparent,
        transparent 8px,
        rgba(0, 0, 0, 0.1) 8px,
        rgba(0, 0, 0, 0.1) 10px
    );
}

/* Mobile optimization */
@media (max-width: 768px) {
    .splash-loader-container {
        width: 70%;
        bottom: 61%; /* Optimale Position unter "POWERHABIT" */
    }

    .splash-loader-bg {
        height: 14px;
        border: 2px solid rgba(255, 255, 255, 0.4);
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .splash-loader-container {
        width: 68%;
        bottom: 61%; /* Optimale Position unter "POWERHABIT" */
    }

    .splash-loader-bg {
        height: 12px;
    }
}

/* ==================== DESKTOP SIDEBAR NAVIGATION ==================== */

/* Hide Desktop Sidebar on Mobile */
.desktop-sidebar {
    display: none;
}

/* Desktop Layout: Sidebar + Main Content */
@media (min-width: 769px) {
    /* Hide splash screen on desktop */
    #splash-screen {
        display: none !important;
    }

    /* Desktop Sidebar Visible */
    .desktop-sidebar {
        display: flex;
        flex-direction: column;
        position: fixed;
        left: calc(50% - 770px); /* Center: 500px (half content) + 250px (sidebar) + 20px (gap) */
        top: 0;
        bottom: 0;
        width: 250px;
        background: var(--bg);
        border-right: none; /* No separator line */
        padding: 160px 16px 24px 16px; /* Top padding to align with content */
        gap: 8px;
        z-index: 100;
    }

    .desktop-sidebar-item {
        display: flex;
        align-items: center;
        gap: 12px;
        background: none;
        border: none;
        padding: 12px 16px;
        cursor: pointer;
        transition: all 0.2s ease;
        color: var(--muted);
        border-radius: 8px;
        text-align: left;
        font-size: 1rem;
    }

    .desktop-sidebar-item:hover {
        background: var(--border-color);
        color: var(--fg);
    }

    .desktop-sidebar-item.active {
        background: var(--border-color);
        color: var(--fg);
        font-weight: 600;
    }

    .desktop-sidebar-icon {
        width: 24px;
        height: 24px;
        stroke: currentColor;
        flex-shrink: 0;
    }

    .desktop-sidebar-label {
        font-size: 0.95rem;
        font-weight: 600;
    }

    /* Adjust container for centered layout */
    .container {
        margin-left: auto;
        margin-right: auto;
        max-width: 1000px;
        padding-top: 24px;
        padding-left: 50px; /* Extra spacing from sidebar */
        position: relative; /* Make container a positioning context for hamburger button */
    }

    /* Show hamburger button on desktop (next to sidebar) */
    .hamburger-btn {
        display: flex !important;
        position: fixed;
        top: 24px;
        left: calc(50% - 770px + 250px + 20px); /* Align with sidebar: center - half content - sidebar width + gap */
        width: 44px;
        height: 44px;
        background: var(--bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 1000;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        transition: all 0.2s ease;
    }

    .hamburger-btn:hover {
        background: var(--bg-secondary);
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    /* Hide footer on desktop (all links are in hamburger menu) */
    .page-footer {
        display: none !important;
    }
}

