:root {
  --bg: #f1ede5;
  --surface: #fffdfa;
  --text: #111827;
  --muted: #374151;
  --line: #b8aa92;
  --accent: #0f4a66;
  --accent-2: #1b6f5b;
  --danger: #ba1a1a;
  --focus: #0b5fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Noto Sans", "Segoe UI", sans-serif;
  line-height: 1.45;
  background: linear-gradient(180deg, #f6f2e9 0%, #e8decb 100%);
  color: var(--text);
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -40px;
  background: #ffffff;
  border: 2px solid var(--focus);
  color: var(--text);
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  z-index: 1000;
}

.skip-link:focus {
  top: 0.5rem;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: #faf8f1;
  position: sticky;
  top: 0;
}

.topbar h1 {
  margin: 0;
  font-size: 1.2rem;
}

.topbar p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.container {
  max-width: 980px;
  margin: 1rem auto;
  padding: 0 1rem 2rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.auth-card {
  max-width: 520px;
  margin: 2rem auto;
}

.signin-buttons {
  display: flex;
  gap: 0.7rem;
}

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  min-height: 2.65rem;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font-weight: 600;
}

.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn:hover { filter: brightness(0.98); }

.hidden { display: none; }

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 0.8rem;
}

.control-group label {
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.9rem;
  color: var(--text);
  font-weight: 600;
}

input:not([type="radio"]), select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 2.65rem;
  padding: 0.52rem 0.6rem;
  background: #fff;
  color: var(--text);
}

.tabs {
  display: flex;
  gap: 0.6rem;
}

.tab {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  min-height: 2.5rem;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  font-weight: 600;
}

.tab.active {
  background: #dbeafe;
  border-color: #6894d8;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.row.space-between {
  justify-content: space-between;
}

#daily-form {
  display: grid;
  gap: 1rem;
}

.field-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem;
  background: #fff;
}

.field-title {
  font-weight: 600;
  margin-bottom: 0.6rem;
}

.input-with-clear {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.4rem;
}

.input-clear-btn {
  width: auto;
  height: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
  line-height: 1;
  color: #8a1c1c;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 0.1rem 0.2rem;
}

.input-clear-btn:hover {
  text-decoration: underline;
}

.choice-clear-btn {
  border: 0;
  background: transparent;
  color: #8a1c1c;
  font-weight: 700;
  font-size: 1.15rem;
  line-height: 1;
  padding: 0.1rem 0.2rem;
  cursor: pointer;
}

.choice-clear-btn:hover {
  text-decoration: underline;
}

.prayer-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(100px, 1fr));
  gap: 0.65rem;
}

.yes-no {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.yes-no-option {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
}

.yes-no-option input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
}

.weekly-table {
  width: 100%;
  border-collapse: collapse;
  overflow: auto;
  display: block;
}

.weekly-table th,
.weekly-table td {
  border: 1px solid var(--line);
  padding: 0.45rem;
  font-size: 0.88rem;
  text-align: left;
  min-width: 180px;
  vertical-align: top;
}

.weekly-cell-line {
  margin-bottom: 0.2rem;
  line-height: 1.25;
  font-size: 0.8rem;
}

.weekly-day-jump {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.weekly-day-cell {
  cursor: pointer;
}

.monthly-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 0.65rem;
}

.progress-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.8rem;
  background: #fff;
  margin-bottom: 0.9rem;
}

.progress-chart {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(32px, 1fr));
  gap: 0.4rem;
  align-items: end;
  min-height: 150px;
  margin-top: 0.5rem;
}

.progress-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.progress-bar-wrap {
  width: 100%;
  height: 96px;
  border: 1px solid #d5c9b3;
  border-radius: 6px;
  background: #f6f2e8;
  display: flex;
  align-items: flex-end;
}

.progress-bar {
  width: 100%;
  border-radius: 6px;
  background: linear-gradient(180deg, #4f8db4 0%, #0f4a66 100%);
}

.progress-day.future .progress-bar {
  background: #cfcfcf;
}

.progress-day-label {
  font-size: 0.72rem;
  color: var(--muted);
}

.day-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem;
  background: #fff;
  text-align: left;
}

.day-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  margin-top: 0.22rem;
}

.day-summary-row span {
  color: var(--muted);
}

.day-summary-bar {
  width: 100%;
  height: 0.35rem;
  border-radius: 999px;
  background: #e4ddcf;
  margin-top: 0.2rem;
}

.day-summary-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: #0f4a66;
}

.summary-ellipsis {
  display: inline-block;
  max-width: 6.6rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-card.done {
  border-color: #8db79d;
  background: #f0faf2;
}

.day-card.future {
  opacity: 0.55;
  cursor: not-allowed;
  background: #f5f3ef;
}

.note {
  color: var(--muted);
  font-size: 0.9rem;
}

.error {
  color: var(--danger);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.save-status {
  min-height: 1.35rem;
  margin: 0 0 0.65rem;
  color: var(--muted);
  font-size: 0.9rem;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 760px) {
  .controls {
    grid-template-columns: 1fr;
  }

  .prayer-grid {
    grid-template-columns: 1fr;
  }

  .row.space-between {
    flex-direction: column;
    align-items: flex-start;
  }
}
