:root {
  --header-bg: #010409;
  --bg: #0d1117;
  --panel: #151b23;
  --border: #3d444d;
  --border-subtle: #30363d;
  --text: #f0f6fc;
  --muted: #9198a1;
  --link: #4493f8;
  --accent: #1f883d;
  --accent-hover: #238636;
  --danger: #da3633;
  --danger-hover: #b62324;
  --success: #3fb950;
  --gh-0: #161b22;
  --gh-1: #0e4429;
  --gh-2: #006d32;
  --gh-3: #26a641;
  --gh-4: #39d353;
  --vac: #388bfd;
  --hol: #db8c2a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
    Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---- header (GitHub-style) ---- */

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 48px;
  padding: 0 24px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

nav {
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 13px;
}
nav a { color: var(--muted); text-decoration: none; }
nav a:hover { color: var(--text); }

/* ---- layout ---- */

main {
  max-width: 960px;
  margin: 24px auto;
  padding: 0 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---- cards ---- */

.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px;
}
.card.center { text-align: center; padding: 40px 24px; }
.card.danger { border-color: rgba(218, 54, 51, 0.4); }

/* ---- typography ---- */

h1, h2, h3 { margin: 0 0 8px 0; font-weight: 600; }
h1 { font-size: 24px; }
h2 { font-size: 16px; border-bottom: 1px solid var(--border-subtle); padding-bottom: 8px; margin-bottom: 16px; }
h3 { font-size: 14px; }

.muted { color: var(--muted); }
.small { font-size: 12px; }

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

code {
  background: rgba(110, 118, 129, 0.2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 85%;
}

/* ---- buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 16px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #212830;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  line-height: 20px;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover {
  background: #262c36;
  border-color: #525a64;
  text-decoration: none;
}
.btn:active { background: #30363d; }

.btn.primary {
  background: var(--accent);
  border-color: rgba(240, 246, 252, 0.1);
  color: #fff;
}
.btn.primary:hover { background: var(--accent-hover); }
.btn.primary:active { background: #2d9340; }

.btn.danger {
  background: var(--danger);
  border-color: rgba(240, 246, 252, 0.1);
  color: #fff;
}
.btn.danger:hover { background: var(--danger-hover); }

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

ol li, ul.commits li { margin: 4px 0; }
ol .btn { margin-left: 8px; }

ul.commits { list-style: none; padding: 0; }

/* ---- contribution graph ---- */

.graph-months {
  display: flex;
  margin-bottom: 3px;
  min-height: 18px;
}
.graph-days-spacer {
  width: 32px;
  flex-shrink: 0;
}
.graph-months-row {
  display: grid;
}
.graph-month-label {
  font-size: 12px;
  color: var(--muted);
  line-height: 18px;
}

.graph-grid-row {
  display: flex;
}

.graph-days {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  gap: 3px;
  width: 32px;
  flex-shrink: 0;
  margin-right: 4px;
  padding-top: 1px;
}
.graph-days span {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
  line-height: 11px;
}

.contrib-graph {
  display: grid;
  grid-template-rows: repeat(7, 11px);
  grid-auto-flow: column;
  grid-auto-columns: 11px;
  gap: 3px;
  padding: 0;
}
.contrib-graph:focus { outline: none; }

.contrib-cell {
  width: 11px;
  height: 11px;
  border-radius: 2px;
  background: var(--gh-0);
  outline: 1px solid rgba(240, 246, 252, 0.04);
  outline-offset: -1px;
}
.contrib-cell.level-0 { background: var(--gh-0); outline: none; }
.contrib-cell.level-1 { background: var(--gh-1); outline: none; }
.contrib-cell.level-2 { background: var(--gh-2); outline: none; }
.contrib-cell.level-3 { background: var(--gh-3); outline: none; }
.contrib-cell.level-4 { background: var(--gh-4); outline: none; }
.contrib-cell.kind-vacation { background: var(--vac); outline: none; }
.contrib-cell.kind-holiday { background: var(--hol); outline: none; }
.contrib-cell.empty { visibility: hidden; }

.legend-sep {
  display: inline-block;
  width: 1px;
  height: 11px;
  background: var(--border);
  margin: 0 4px;
}

.graph-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.contrib-legend {
  display: flex;
  gap: 4px;
  align-items: center;
  font-size: 11px;
  color: var(--muted);
}
.contrib-legend .contrib-cell { display: inline-block; outline: 1px solid rgba(240, 246, 252, 0.06); outline-offset: -1px; }
.contrib-legend .contrib-cell.level-0 { outline: none; }

/* ---- config form ---- */

.config-form {
  margin-bottom: 20px;
}

.config-form fieldset {
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px;
  margin: 0 0 12px 0;
}
.config-form legend {
  padding: 0 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}
.config-form fieldset > label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: var(--muted);
  gap: 4px;
}
.config-form input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 10px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
  width: 100%;
  max-width: 100px;
}
.config-form input[type="number"]:focus {
  border-color: var(--link);
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.3);
}

/* ---- simulation ---- */

.simulation-panel {
  margin-top: 16px;
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  background: #0a0d11;
}
#graph-container {
  position: relative;
}

.graph-wrapper {
  overflow-x: auto;
  padding-bottom: 2px;
}

.graph-inner {
  width: fit-content;
  margin: 0 auto;
}

.sim-stats {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}
.sim-stats strong { color: var(--text); }

/* ---- state bar ---- */

.day-banner {
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  border: 1px solid var(--border-subtle);
}
.day-banner.vacation {
  border-left: 3px solid var(--vac);
  background: rgba(56, 139, 253, 0.12);
}
.day-banner.holiday {
  border-left: 3px solid var(--hol);
  background: rgba(219, 140, 42, 0.1);
}
.day-banner.working {
  border-left: 3px solid var(--success);
  background: rgba(63, 185, 80, 0.1);
}

.state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 8px;
}
.state-grid > div {
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
}
.state-grid .muted { display: block; margin-bottom: 2px; }
.state-grid strong { font-size: 15px; }

/* ---- manual commit ---- */

.manual-commit {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.manual-commit input[type="text"] {
  flex: 1;
  min-width: 200px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 5px 10px;
  font-size: 13px;
}
.manual-commit input[type="text"]:focus {
  border-color: var(--link);
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.3);
}

.success { color: var(--success); }
.error { color: var(--danger); }

/* ---- preset buttons ---- */

.preset-bar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.timeoff-toggle {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
}
.timeoff-toggle input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--accent);
  cursor: pointer;
}
.preset-btn { min-width: 64px; text-align: center; }
.preset-btn.active {
  background: var(--accent);
  border-color: rgba(240, 246, 252, 0.1);
  color: #fff;
}

/* ---- intensity sliders ---- */

.slider-label {
  display: grid !important;
  grid-template-columns: 40px 1fr 60px !important;
  align-items: center;
  gap: 8px !important;
  padding: 3px 0;
}
.slider-label > span:first-child {
  font-weight: 500;
  font-size: 13px !important;
  color: var(--text) !important;
}
.intensity-value {
  text-align: right;
  font-size: 12px;
  color: var(--text);
}
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  border: 1px solid var(--border);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  cursor: pointer;
  border: 1px solid var(--border);
}
input[type="range"]:focus::-webkit-slider-thumb {
  background: var(--link);
  border-color: var(--link);
}

/* ---- setup page ---- */

.setup-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 480px;
}
.setup-form label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}
.setup-form select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  padding: 6px 10px;
  font-size: 13px;
  font-family: ui-monospace, monospace;
}
.setup-form select:focus {
  border-color: var(--link);
  outline: none;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.3);
}
.setup-empty { margin-top: 16px; }
.setup-empty ol { padding-left: 20px; }
.setup-empty li { margin: 8px 0; }

/* ---- spinner ---- */

.spinner {
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin-right: 6px;
  flex-shrink: 0;
}
.spinner.htmx-request { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- tooltip ---- */

.graph-tooltip {
  position: absolute;
  background: #1c2128;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 11px;
  padding: 4px 8px;
  pointer-events: none;
  white-space: nowrap;
  z-index: 100;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
}

/* ---- form actions ---- */

.form-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- responsive ---- */

@media (max-width: 760px) {
  main { padding: 0 12px; }
  header { padding: 0 12px; }
}
