* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-serif);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Original header styles - but now it's app-header */
header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}

.app {
  width: min(60vw, 1240px);
  max-width: calc(100vw - 48px);
  display: flex;
  flex-direction: column;
  gap: 60px;
}

.app-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.content-area {
  display: flex;
  flex-direction: column;
  flex: 1;
}

#today {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: clamp(18px, 2.5vw, 28px);
  line-height: 1.2;
}

#hint {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
  text-align: right;
}

.gridWrap {
  width: 100%;
  overflow: visible;
  margin: 0 auto;
  flex: 1;
}

.grid {
  width: 100%;
  display: grid;

  /* 13 x 33 */
  grid-template-columns: var(--month-col) repeat(31, var(--dot-size));
  grid-template-rows: repeat(13, max(22px, var(--dot-size)));
  gap: var(--row-gap) var(--col-gap);
  align-items: center;
}

.cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
}

.cell.header {
  font-family: var(--font-sans);
  font-size: 12px;
  color: var(--muted);
}

.cell.month {
  justify-content: center;
  text-align: center;
  font-weight: 650;
  font-size: 14px;
  white-space: nowrap;
}

.app-footer {
  position: fixed;
  right: 18px;
  bottom: 18px;
}

.githubLink {
  color: var(--dot);
  text-decoration: none;
  line-height: 0;
  display: block;
}

.githubLink:visited {
  color: var(--dot);
}

.githubLink:hover {
  color: var(--dot-weekend);
}

.githubLink:focus-visible {
  outline: none;
  border-radius: 6px;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.githubLink svg,
.githubLink i {
  width: 28px;
  height: 28px;
  display: block;
  fill: currentcolor;
  font-size: 28px;
}

/* Shared icon button styling */
.githubLink,
.navigationButton {
  color: var(--dot);
  text-decoration: none;
  line-height: 0;
  display: block;
}

.githubLink:visited,
.navigationButton:visited {
  color: var(--dot);
}

.githubLink:hover,
.navigationButton:hover {
  color: var(--dot-weekend);
}

.githubLink:focus-visible,
.navigationButton:focus-visible {
  outline: none;
  border-radius: 6px;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.githubLink i,
.navigationButton i {
  width: 24px;
  height: 24px;
  display: block;
  font-size: 24px;
}

.navigationButtons {
  position: fixed;
  right: var(--settings-button-position);
  top: var(--settings-button-position);
  display: flex;
  gap: 12px;
}

.navigationButton {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.settings-content {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}

.settings-content > * {
  pointer-events: auto;
}

.settingsBackdrop {
  position: fixed;
  inset: 0;
  background: var(--backdrop);
  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease;
}

.settingsPanel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: var(--settings-panel-width);
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  transform: translateX(100%);
  transition: transform 220ms cubic-bezier(0.2, 0.85, 0.2, 1);
  z-index: 30;
  padding: var(--settings-panel-padding);
  display: none;
  flex-direction: column;
  gap: var(--header-gap);
}

body.settingsOpen .settingsBackdrop {
  opacity: 1;
  pointer-events: auto;
}

body.settingsOpen .settingsPanel {
  transform: translateX(0);
  display: flex;
}

.settingsPanel[inert] {
  pointer-events: none;
  opacity: 0.5;
}

.settingsPanelHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--theme-tile-gap);
}

.settingsPanelTitle {
  font-family: var(--font-sans);
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.settingsClose {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 8px;
  margin: 0;
  color: var(--muted);
  cursor: pointer;
  font-size: var(--close-button-size);
  line-height: 1;
  position: relative;
  z-index: 40;
  pointer-events: auto;
  min-width: 30px;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settingsClose:hover {
  color: var(--text);
}

.settingsClose:focus-visible {
  outline: none;
  border-radius: 8px;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.settingsContent {
  flex: 1;
  overflow: hidden auto;

  /* Themed scrollbar for WebKit browsers (Chrome, Safari, Edge) */
  &::-webkit-scrollbar {
    width: 8px;
  }

  &::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 4px;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
    transition: background 0.2s ease;
  }

  &::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
  }

  /* Firefox scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.documentation-content {
  padding: 16px;
  color: var(--text-primary);
  line-height: 1.6;
  font-family: var(--font-sans);
}

.documentation-section {
  margin-bottom: 24px;
}

.documentation-section h2,
.documentation-section h3 {
  margin: 0 0 12px;
  color: var(--text-primary);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-serif);
}

.documentation-section h2 {
  font-size: 18px;
}

.documentation-section h3 {
  font-size: 16px;
}

.documentation-section p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}

.documentation-section ul,
.documentation-section ol {
  margin: 0 0 12px;
  padding-left: 20px;
  color: var(--text-secondary);
}

.documentation-section li {
  margin-bottom: 6px;
}

.documentation-section kbd {
  background: var(--background-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: monospace;
  font-size: 12px;
  color: var(--text-primary);
}

.documentation-section i {
  color: var(--accent-color);
  font-size: 16px;
}

.documentation-section a {
  color: var(--accent-color);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: var(--accent-color);
  text-underline-offset: 2px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s ease;
}

.documentation-section a:hover {
  opacity: 0.8;
}

.documentation-section a::before {
  content: "\f08e";
  font-family: "Font Awesome 6 Free", sans-serif;
  font-weight: 900;
  font-size: 12px;
}

/* README link styling (for consistency) */
main a {
  color: var(--accent-color);
  text-decoration: underline;
  text-decoration-style: dashed;
  text-decoration-color: var(--accent-color);
  text-underline-offset: 2px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: opacity 0.2s ease;
}

main a:hover {
  opacity: 0.8;
}

main a::before {
  content: "\f08e";
  font-family: "Font Awesome 6 Free", sans-serif;
  font-weight: 900;
  font-size: 12px;
}

.themeList {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--theme-tile-gap);
  overflow-y: auto;
  padding-right: 8px;

  /* Themed scrollbar for WebKit browsers */
  &::-webkit-scrollbar {
    width: 6px;
  }

  &::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
    border-radius: 3px;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
    transition: background 0.2s ease;
  }

  &::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
  }

  /* Firefox scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.themeTile {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: transparent;
  padding: var(--theme-tile-padding);
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
  color: inherit;
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--theme-tile-padding);
}

.themeTile:hover {
  border-color: rgb(127 127 127 / 38%);
}

.themeTile[aria-pressed="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(127 127 127 / 12%);
}

.themeTile:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--focus-ring);
}

.themeSwatch {
  height: var(--theme-swatch-height);
  border-radius: 12px;
  border: 1px solid rgb(127 127 127 / 20%);
  overflow: hidden;
}

.themeMeta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.themeName {
  font-weight: 650;
  letter-spacing: -0.01em;
}

.themeFonts {
  font-family: var(--font-sans);
  color: var(--muted);
  font-size: 12px;
}

.cell.day {
  cursor: pointer;
}

.dot {
  width: var(--dot-size);
  height: var(--dot-size);
  border-radius: 999px;
  background: var(--dot);
  transition:
    transform 90ms ease,
    box-shadow 120ms ease,
    background-color 120ms ease;
}

.cell.weekend .dot {
  background: var(--dot-weekend);
}

.cell.invalid {
  cursor: default;
}

.cell.invalid .dot {
  background: var(--invalid);
  opacity: 0.2;
}

.cell.marked .dot {
  background: var(--accent);
}

.cell.day:hover .dot {
  box-shadow: 0 0 0 3px var(--hover-ring);
}

/* Highlight the current day using themeable variables */
.cell.today .dot {
  background: var(--today-dot);
  box-shadow: 0 0 0 3px var(--today-ring);
}

/* If today is marked, use the same fill as other marked days but keep the ring */
.cell.today.marked .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--today-ring-strong);
}

/* Hover still works, but uses a subtle ring on top */
.cell.today.day:hover .dot {
  box-shadow: 0 0 0 3px var(--today-ring-strong);
}

.cell.day:active .dot {
  transform: scale(0.9);
}

/* Keep hover ring readable on marked dots */
.cell.day.marked:hover .dot {
  box-shadow: 0 0 0 3px rgb(17 17 17 / 18%);
}

@media (prefers-reduced-motion: reduce) {
  .dot {
    transition: none;
  }

  .cell.day:active .dot {
    transform: none;
  }
}

/* Global themed scrollbar styling */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
  transition: background 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Firefox scrollbar styling */
html {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}

.onboarding-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
}

.onboarding-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.onboarding-greeting {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: clamp(32px, 6vw, 64px);
  line-height: 1.1;
  color: var(--text);
  font-family: var(--font-serif);
  display: flex;
  align-items: center;
  gap: 0;
}

.name-input {
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  color: var(--text);
  width: 4em; /* Fixed width */
  padding: 0;
  margin: 0 0 0 12px;
  text-align: left;
}

.name-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.onboarding-question {
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-size: clamp(32px, 6vw, 64px);
  line-height: 1.1;
  color: var(--text);
  font-family: var(--font-serif);
}

.goal-input {
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  color: var(--text);
  width: 20em;
  max-width: 80%;
  padding: 8px 0;
  margin: 16px 0;
  text-align: center;
}

.goal-input::placeholder {
  color: var(--muted);
  opacity: 0.6;
}

.onboarding-hint {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.3;
}
