:root {
  --white: #ffffff;
  --gray: #c9c9c9;
  --black: #000000;
  --muted: #555555;
  --past: #eeeeee;
  --border: #cccccc;
  --danger: #a32d2d;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  padding: 24px;
  color: var(--black);
  background: var(--white);
}

main {
  max-width: 900px;
  margin: 0 auto;
}

h1 {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 16px;
}

.hidden {
  display: none;
}

/* New countdown form */
.new-form {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 8px;
}

.new-form label {
  display: flex;
  flex-direction: column;
  font-size: 13px;
  color: var(--muted);
  gap: 4px;
}

.new-form input {
  padding: 6px 8px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.new-form button {
  padding: 8px 16px;
  font-size: 14px;
  border: 1px solid var(--black);
  border-radius: 4px;
  background: var(--black);
  color: var(--white);
  cursor: pointer;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin: 4px 0 20px;
}

/* Countdown list */
.countdown-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.countdown-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
}

.countdown-info {
  cursor: pointer;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.countdown-label {
  font-weight: 600;
  font-size: 14px;
  min-width: 160px;
}

.countdown-range {
  font-size: 13px;
  color: var(--muted);
}

.countdown-status {
  font-size: 13px;
  font-weight: 600;
  margin-left: auto;
}

/* Buttons */
.ghost-btn {
  padding: 6px 12px;
  font-size: 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--white);
  cursor: pointer;
}

.danger-btn {
  padding: 8px 14px;
  font-size: 13px;
  border: 1px solid var(--danger);
  border-radius: 4px;
  background: var(--white);
  color: var(--danger);
  cursor: pointer;
}

.danger-btn.small {
  padding: 4px 10px;
  font-size: 12px;
}

/* Detail view */
.detail-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
}

.detail-header h1 {
  margin: 0;
  flex: 1;
}

.legend {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid var(--black);
  display: inline-block;
}

.swatch.rest { background: var(--white); }
.swatch.work { background: var(--gray); }
.swatch.past { background: var(--past); }

/* Calendar grid (shared) */
.month-block {
  margin-bottom: 32px;
}

.month-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.dow-row,
.day-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.dow-row {
  margin-bottom: 4px;
}

.dow-cell {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

.day-cell {
  border: 1px solid var(--black);
  border-radius: 4px;
  min-height: 64px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  background: var(--gray);
}

.day-cell.rest {
  background: var(--white);
}

.day-cell.past {
  background: var(--past);
}

.day-cell.empty {
  visibility: hidden;
}

.date-num {
  font-size: 11px;
  color: var(--muted);
}

.countdown {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 18px;
  font-weight: 600;
}

.countdown.due {
  font-size: 13px;
}

.past-mark {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 18px;
  font-weight: 600;
  color: var(--muted);
}

@media print {
  .new-form,
  .hint,
  .detail-header .ghost-btn,
  .detail-header .danger-btn,
  .legend,
  .month-nav {
    display: none;
  }
  body {
    padding: 0;
  }
}


/* Login page */
.login-main {
  max-width: 360px;
  margin: 80px auto 0;
}

.login-form {
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
}

.login-form button {
  margin-top: 4px;
}

.error-text {
  color: var(--danger);
  font-size: 13px;
  margin-top: 12px;
}

/* Month navigation (detail view) */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 16px;
}

.month-position {
  font-size: 13px;
  color: var(--muted);
  min-width: 110px;
  text-align: center;
}

.ghost-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Mobile tightening */
@media (max-width: 480px) {
  body {
    padding: 12px;
  }

  .day-cell {
    min-height: 52px;
    padding: 4px;
  }

  .date-num {
    font-size: 10px;
  }

  .countdown,
  .past-mark {
    font-size: 15px;
  }

  .countdown.due {
    font-size: 11px;
  }

  .swatch {
    width: 10px;
    height: 10px;
  }

  .legend {
    gap: 10px;
    font-size: 11px;
  }
}