:root {
  color-scheme: light;
  --background: #f4f6f9;
  --surface: #fff;
  --surface-alt: #eef2f6;
  --text: #17202a;
  --muted: #657180;
  --border: #d9e0e7;
  --accent: #1f66d1;
  --accent-hover: #174fa5;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(28, 39, 54, 0.14);
  --wheel-grid: #cbd4df;
  --wheel-center: #f8fafc;
  --dim-opacity: 0.14;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}
h1,
h2,
p {
  margin-top: 0;
}
h1 {
  font-size: 1.45rem;
  margin-bottom: 0;
}
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 94%, transparent);
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(14px);
}
.header-actions,
.year-navigation,
.inline-fields,
.modal-footer,
.split-footer {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.header-select {
  min-width: 160px;
}
.user-name {
  font-size: 0.85rem;
  color: var(--muted);
}
.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 1rem;
  padding: 1rem;
  height: calc(100vh - 78px);
}
.wheel-panel,
.event-panel,
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 6px 24px rgba(28, 39, 54, 0.06);
  min-height: 0;
}
.wheel-panel {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}
.toolbar h2 {
  font-size: 1.2em;
  margin: 0;
  min-width: 4rem;
  text-align: center;
}
.today-date {
  margin: 0;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 750;
  text-align: center;
}
.category-filters,
.category-chip-row,
.category-choice-grid {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.45rem;
}
.filter-chip,
.category-chip,
.category-choice {
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--text);
  border-radius: 999px;
  padding: 0.4rem 0.65rem;
  font-weight: 700;
  font-size: 0.78rem;
  cursor: pointer;
}
.filter-chip.off {
  opacity: 0.42;
  text-decoration: line-through;
}
.color-dot {
  display: inline-block;
  width: 0.68rem;
  height: 0.68rem;
  border-radius: 50%;
  margin-right: 0.35rem;
}
.wheel-container {
  position: relative;
  min-height: 0;
  flex: 1;
  display: grid;
  place-items: center;
  padding: 0.5rem;
}
.annual-wheel {
  width: min(100%, calc(100vh - 165px));
  height: min(100%, calc(100vh - 165px));
  min-height: 500px;
  overflow: visible;
}
.calendar-label {
  fill: var(--muted);
  font-weight: 900;
}
.month-label {
  font-size: 26px;
  letter-spacing: 0.08em;
}
.week-label {
  font-size: 22px;
  letter-spacing: 0.04em;
}
.year-grid {
  fill: none;
  stroke: var(--wheel-grid);
}
.category-grid {
  fill: none;
}
.event-arc {
  fill: none;
  cursor: pointer;
  transition:
    opacity 0.18s,
    filter 0.18s,
    stroke-width 0.18s;
}
.event-arc:hover,
.event-arc.selected,
.event-arc.hovered {
  filter: drop-shadow(0 0 7px rgba(0, 0, 0, 0.28)) brightness(1.1);
}
.events-dimmed .event-arc:not(.selected),
.events-hovering .event-arc:not(.hovered):not(.selected) {
  opacity: var(--dim-opacity);
}
.today-line {
  stroke: #ff4545;
  stroke-width: 4;
  stroke-linecap: round;
  opacity: 0.5;
}
.today-dot {
  fill: #ff4545;
  stroke: var(--surface);
  stroke-width: 3;
}
.wheel-tooltip {
  position: absolute;
  z-index: 8;
  max-width: 260px;
  padding: 0.55rem 0.7rem;
  background: var(--text);
  color: var(--surface);
  border-radius: 8px;
  font-size: 0.78rem;
  pointer-events: none;
  box-shadow: var(--shadow);
}
.event-panel {
  display: flex;
  flex-direction: column;
  padding: 1rem;
  overflow: hidden;
}
.event-panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: start;
}
.eyebrow {
  letter-spacing: 0.12em;
  font-size: 0.69rem;
  font-weight: 800;
  color: var(--muted);
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}
.count-badge {
  min-width: 2rem;
  text-align: center;
  background: var(--surface-alt);
  border-radius: 999px;
  padding: 0.3rem 0.55rem;
  font-weight: 800;
}
.search-field input {
  width: 100%;
  margin-bottom: 0.8rem;
}
.event-list {
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-right: 0.2rem;
}
.event-list-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 0.75rem;
  cursor: pointer;
  transition: 0.16s;
}
.event-list-item:hover,
.event-list-item.selected,
.event-list-item.hovered {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 5px 15px rgba(30, 80, 140, 0.14);
}
.event-list.dimmed .event-list-item:not(.selected),
.event-list.hovering .event-list-item:not(.hovered):not(.selected) {
  opacity: 0.35;
}
.event-list-item.past {
  opacity: 0.48;
  filter: saturate(0.6);
}
.event-list-item.past:hover,
.event-list-item.past.hovered,
.event-list-item.past.selected {
  opacity: 1;
  filter: none;
}
.event-list-item strong {
  display: block;
  margin-bottom: 0.25rem;
}
.event-list-meta {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.75rem;
}
.recurrence-badge {
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 800;
  margin-left: 0.4rem;
}
.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 2.5rem 0.5rem;
}
.status-message {
  padding: 0.7rem 1rem;
  background: #fff3cd;
  color: #664d03;
}
.view-toggle {
  display: inline-flex;
  padding: 0.2rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-alt);
}
.view-toggle-button {
  border: 0;
  border-radius: 7px;
  padding: 0.42rem 0.65rem;
  background: transparent;
  color: var(--muted);
  font-weight: 750;
}
.view-toggle-button.selected {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 5px rgba(28, 39, 54, 0.12);
}
button,
input,
textarea,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  border-radius: 9px;
  border: 1px solid transparent;
  padding: 0.6rem 0.85rem;
  font-weight: 750;
  text-decoration: none;
}
.primary-button {
  background: var(--accent);
  color: #fff;
}
.primary-button:hover {
  background: var(--accent-hover);
}
.secondary-button,
.icon-button {
  background: var(--surface-alt);
  color: var(--text);
  border-color: var(--border);
}
.danger-button {
  background: #fee4e2;
  color: var(--danger);
  border-color: #fecdca;
}
.icon-button {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  font-size: 1.25rem;
}
.compact {
  padding: 0.42rem 0.65rem;
}
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(12, 18, 28, 0.58);
  backdrop-filter: blur(4px);
}
.modal-backdrop[hidden] {
  display: none;
}
.modal {
  width: min(700px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.modal-header,
.modal-body,
.modal-footer {
  padding: 1.15rem 1.25rem;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 {
  margin-bottom: 0;
}
.modal-footer {
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}
.split-footer {
  justify-content: space-between;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
.detail-label {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  margin-bottom: 0.35rem;
}
.description-box {
  margin-top: 1.25rem;
  padding: 1rem;
  line-height: 1.55;
  background: var(--surface-alt);
  border-radius: 12px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
label,
legend {
  font-weight: 700;
  font-size: 0.86rem;
}
input,
textarea,
select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.68rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
}
textarea {
  resize: vertical;
}
.inline-fields > * {
  flex: 1;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0;
}
.field-hint {
  font-size: 0.77rem;
  color: var(--muted);
  margin: 0.4rem 0 0;
}
.category-choice.selected {
  box-shadow: inset 0 0 0 2px currentColor;
}
.new-category-box,
.recurrence-box {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 0.75rem;
}
.form-error {
  padding: 0.7rem;
  background: #fee4e2;
  color: #912018;
  border-radius: 8px;
  margin: 0;
}
.category-manager-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.category-row {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0.7rem;
  align-items: center;
  padding: 0.6rem;
  background: var(--surface-alt);
  border-radius: 10px;
}
.category-row input {
  margin: 0;
}
.category-row input[type="color"] {
  height: 42px;
  padding: 0.2rem;
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}
.auth-card {
  width: min(430px, calc(100% - 2rem));
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  padding: 1rem;
}
.admin-card {
  padding: 1rem;
}
.admin-wide {
  grid-column: 1/-1;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.65rem;
  border-bottom: 1px solid var(--border);
}
.check-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.check-label input {
  width: auto;
  margin: 0;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --background: #0c1118;
    --surface: #151c25;
    --surface-alt: #202a36;
    --text: #edf2f7;
    --muted: #9cabbc;
    --border: #334151;
    --accent: #6ca5ff;
    --accent-hover: #8bb7ff;
    --danger: #ff8b82;
    --wheel-grid: #3b4858;
    --wheel-center: #121923;
    --dim-opacity: 0.17;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --background: #0c1118;
  --surface: #151c25;
  --surface-alt: #202a36;
  --text: #edf2f7;
  --muted: #9cabbc;
  --border: #334151;
  --accent: #6ca5ff;
  --accent-hover: #8bb7ff;
  --danger: #ff8b82;
  --wheel-grid: #3b4858;
  --wheel-center: #121923;
  --dim-opacity: 0.17;
}
@media (max-width: 900px) {
  .app-shell,
  .admin-grid {
    height: auto;
    grid-template-columns: 1fr;
  }
  .annual-wheel {
    min-height: 430px;
    width: 100%;
    height: auto;
  }
  .event-panel {
    max-height: 540px;
  }
  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
  .admin-wide {
    grid-column: auto;
  }
}
@media (max-width: 560px) {
  .app-header {
    align-items: flex-start;
    padding: 0.8rem;
    flex-direction: column;
  }
  .header-actions {
    width: 100%;
    flex-wrap: wrap;
  }
  .app-shell {
    padding: 0.55rem;
  }
  .detail-grid,
  .inline-fields {
    grid-template-columns: 1fr;
    display: grid;
  }
  .split-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .modal-footer button {
    flex: 1;
  }
}
