:root {
  --bg-color: #f5ebe0;
  --text-color: #3b2f25;
  --card-color: #FCF6E8;
}

body {
  margin: 40px auto;
  max-width: 650px;
  line-height: 1.6;
  font-size: 18px;
  color: var(--text-color);
  padding: 0 10px;
  background-color: var(--bg-color);
  position: relative;
  font-family: "EB Garamond", serif;
}

body.dark-mode {
  --bg-color: #0f0f0f;
  --text-color: #f5ebe0;
  --card-color: #1b1b1b;
}

h1,
h2,
h3 {
  line-height: 1.2;
}

a {
  color: inherit;
  text-decoration: underline;
}

a:hover {
  color: #0066cc;
  text-decoration: underline;
}

.link-plain {
  text-decoration: none;
}

.link-plain:hover {
  color: #0066cc;
  text-decoration: none;
}

.theme-toggle {
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: var(--bg-color);
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  padding: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
  transition: background-color 0.2s ease, color 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
}

.theme-toggle:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

.theme-toggle .toggle-icon {
  font-size: 1.2rem;
  line-height: 1;
}

body.dark-mode .theme-toggle {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.45);
}

.site-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  margin-bottom: 28px;
}

.site-nav-links {
  display: flex;
  gap: 18px;
}

.site-nav-links a {
  text-decoration: none;
  color: inherit;
  font-weight: 500;
  font-size: 1.5rem;
  padding-bottom: 2px;
  transition: color 0.2s ease;
}

.site-nav-links a:hover,
.site-nav-links a:focus-visible {
  text-decoration: underline;
  outline: none;
}

.site-nav-links a.is-active {
  text-decoration: underline;
}

.page-header {
  margin-bottom: 36px;
}

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

.header-row h1 {
  margin: 0;
}

.page-header h3 {
  margin: 12px 0 10px;
}

.page-header h4,
.page-header p {
  margin: 0 0 18px;
}

.updates {
  list-style: none;
  padding-left: 0;
  margin: 0 0 20px 0;
}

.updates li {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 12px;
  margin-bottom: 10px;
}

.update-date {
  font-weight: 600;
  white-space: nowrap;
}

.updates a {
  display: inline;
}

.blog-post {
  margin-bottom: 40px;
  padding: 8px 20px 20px;
  background-color: var(--card-color);
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: none;
}

.post-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}

.post-header h2 {
  margin: 0;
  flex: 1;
}

.blog-post a {
  text-decoration: none;
  color: inherit;
}

.blog-post a:visited {
  color: inherit;
}

.blog-post a:hover {
  text-decoration: underline;
  color: inherit;
}

.date {
  color: inherit;
  font-size: 0.95em;
  position: static;
  flex: 0 0 auto;
}

.article-card {
  padding: 5px 28px;
  background-color: var(--card-color);
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.article-meta {
  color: inherit;
  font-size: 0.95em;
  margin-bottom: 20px;
}

.article-content p {
  margin-bottom: 20px;
}

.article-content h2 {
  margin: 32px 0 16px;
}

.card {
  background-color: var(--card-color);
  border-radius: 14px;
  padding: 20px 24px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: none;
}

body.dark-mode .card {
  border-color: rgba(255, 255, 255, 0.15);
}

.card.is-error {
  border-color: #c8553d;
  color: #7c2d19;
}

body.dark-mode .card.is-error {
  border-color: #f29580;
  color: #f4c2b6;
}

.habit-grid {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.habit-grid .habit-card {
  width: 100%;
  max-width: 860px;
  margin-inline: auto;
}

.habit-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.habit-nav-button {
  border: none;
  background: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-family: inherit;
  padding: 0 0 4px;
  text-decoration: none;
  color: inherit;
  position: relative;
}

.habit-nav-button::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: transparent;
}

.habit-nav-button:hover,
.habit-nav-button:focus-visible {
  text-decoration: underline;
  outline: none;
}

.habit-nav-button.is-active::after {
  background: currentColor;
}

.habit-nav-icon {
  font-size: 1.2rem;
}

body.dark-mode .habit-nav-button.is-active::after {
  background: currentColor;
}

.habit-chart {
  margin-top: 12px;
}

.habit-chart svg {
  width: 100%;
  height: auto;
  border: 1px solid rgba(0, 0, 0, 0.15);
  border-radius: 12px;
  overflow: visible;
}

body.dark-mode .habit-chart svg {
  border-color: rgba(255, 255, 255, 0.2);
}

.chart-axis {
  stroke: rgba(0, 0, 0, 0.3);
  stroke-width: 1;
}

.chart-tick {
  stroke: rgba(0, 0, 0, 0.15);
  stroke-width: 1;
}

.chart-label {
  fill: currentColor;
  font-size: 0.75rem;
}

body.dark-mode .chart-axis,
body.dark-mode .chart-tick {
  stroke: rgba(255, 255, 255, 0.3);
}

.chart-target {
  stroke: #4caf50;
  stroke-width: 1.5;
  stroke-dasharray: 6 4;
}

.chart-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 12px;
}

.chart-meta small {
  display: block;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

.chart-meta strong {
  display: block;
  font-size: 1.4rem;
}

.chart-meta span {
  font-size: 0.9rem;
}

.chart-empty {
  font-style: italic;
  margin: 0;
}

@media (max-width: 600px) {
  .chart-meta {
    flex-direction: column;
  }
}

.habit-card-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

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

.habit-title h3 {
  margin: 0;
}

.habit-title p {
  margin: 6px 0 0 0;
  font-size: 0.95rem;
}

.habit-icon {
  font-size: 1.8rem;
  line-height: 1;
}

.habit-tally {
  text-align: right;
  min-width: 110px;
}

.habit-tally strong {
  display: block;
  font-size: 1.4rem;
}

.habit-tally span,
.habit-tally small {
  display: block;
  font-size: 0.85rem;
}

.habit-calendar {
  display: grid;
  grid-template-columns: repeat(15, minmax(0, 1fr));
  gap: 6px;
}

@media (max-width: 640px) {
  .habit-calendar {
    grid-template-columns: repeat(10, minmax(0, 1fr));
  }
}

.calendar-day {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
}

.calendar-day.status-complete {
  background-color: #7fc29b;
  color: #0f2d1b;
}

.calendar-day.status-partial {
  background-color: #e7c46c;
  color: #4b3a06;
}

.calendar-day.status-missed {
  background-color: rgba(200, 85, 61, 0.2);
  color: #7c2d19;
}

body.dark-mode .calendar-day.status-missed {
  background-color: rgba(200, 85, 61, 0.35);
  color: #f6c2b3;
}

.habit-legend {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.legend-item p {
  margin: 2px 0 0 0;
  font-size: 0.9rem;
}

.daily-summary {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
}

.summary-label {
  font-size: 0.9rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin: 0;
}

.summary-metrics {
  text-align: right;
}

.summary-metrics strong {
  font-size: 2rem;
  display: block;
}

.summary-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.summary-status p {
  margin: 0;
}

.link-button {
  border: 1px solid rgba(0, 0, 0, 0.2);
  background: transparent;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  font-size: 1rem;
  font-family: inherit;
  padding: 6px 14px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  line-height: 1.2;
}

.link-button:hover,
.link-button:focus-visible {
  background-color: rgba(0, 0, 0, 0.05);
  text-decoration: none;
  outline: none;
}

body.dark-mode .link-button {
  border-color: rgba(255, 255, 255, 0.3);
}

body.dark-mode .link-button:hover,
body.dark-mode .link-button:focus-visible {
  background-color: rgba(255, 255, 255, 0.1);
}

.habit-daily-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 32px;
}

.daily-card .habit-card-header {
  margin-bottom: 12px;
}

.habit-daily-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.habit-target {
  display: block;
  font-size: 0.85rem;
  margin-top: 4px;
}

.habit-controls {
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.habit-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.habit-checkbox input {
  width: 20px;
  height: 20px;
}

body.dark-mode .habit-checkbox {
  border-color: rgba(255, 255, 255, 0.2);
}

.habit-counter {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 999px;
  padding: 4px 12px;
}

body.dark-mode .habit-counter {
  border-color: rgba(255, 255, 255, 0.2);
}

.counter-button {
  border: none;
  background: none;
  font-size: 1.4rem;
  padding: 6px;
  cursor: pointer;
  color: inherit;
}

.counter-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.counter-value {
  font-size: 1rem;
  min-width: 72px;
  text-align: center;
}

.habit-scale {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.habit-scale input[type="range"] {
  width: 100%;
}

.scale-value {
  align-self: flex-end;
  font-size: 0.9rem;
}

.habit-text {
  width: 100%;
}

.habit-text input {
  width: min(100%, 200px);
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  font-size: 1rem;
  font-family: inherit;
  background-color: var(--card-color);
  color: inherit;
}

body.dark-mode .habit-text input {
  border-color: rgba(255, 255, 255, 0.2);
}

@media (max-width: 600px) {
  .daily-summary {
    flex-direction: column;
    align-items: flex-start;
  }

  .summary-metrics {
    text-align: left;
  }

  .habit-controls {
    justify-content: flex-start;
  }

  .habit-daily-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
}

.favorite-image {
  height: auto;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  max-width: 300px;
}

body.dark-mode .favorite-image {
  border-color: rgba(255, 255, 255, 0.2);
}

.favorites-category-nav {
  justify-content: center;
  margin-bottom: 15px;
}

.favorites-category-nav .habit-nav-button {
  font-size: 1.2rem;
  padding: 8px 16px;
}

.favorites-category-nav .habit-nav-button:hover,
.favorites-category-nav .habit-nav-button:focus-visible {
  text-decoration: none;
}

.favorites-category-container {
  position: relative;
  min-height: 450px;
  display: flex;
  align-items: flex-start;
}

.favorites-category {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.favorites-category.active {
  position: relative;
  opacity: 1;
  visibility: visible;
}

.favorites-slideshow-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
  min-height: 400px;
}

.favorites-slideshow {
  flex: 1;
  position: relative;
  min-height: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.favorite-slide {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  width: 100%;
  max-width: 100%;
  padding: 20px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.favorite-slide.active {
  opacity: 1;
  visibility: visible;
}

.favorite-slide img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  object-fit: contain;
}

.slideshow-arrow {
  background: var(--bg-color);
  border: 1px solid rgba(0, 0, 0, 0.15);
  color: var(--text-color);
  font-size: 1.5rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.slideshow-arrow:hover:not(:disabled) {
  background-color: rgba(0, 0, 0, 0.05);
  transform: scale(1.1);
}

.slideshow-arrow:disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

body.dark-mode .slideshow-arrow {
  border-color: rgba(255, 255, 255, 0.2);
}

body.dark-mode .slideshow-arrow:hover:not(:disabled) {
  background-color: rgba(255, 255, 255, 0.1);
}

@media (max-width: 600px) {
  .slideshow-arrow {
    width: 35px;
    height: 35px;
    font-size: 1.2rem;
  }
  
  .favorites-slideshow {
    min-height: 250px;
  }
}
