/* =========================================================
   DESIGN SYSTEM — BASE
========================================================= */

:root {
  --bg: #f6f7f5;
  --bg-soft: #eef1ee;

  --card: #ffffff;
  --border: #e5e7e4;

  --text: #1f2933;
  --text-muted: #4b5563;
  --text-hint: #9aa1a9;

  --accent: #3a6f6a;
  --accent-soft: #dfeceb;

  --danger: #b4533c;

  --radius: 14px;
}

html { font-size: 16px; }

body {
  margin: 0;
  color: var(--text);
  background-color: var(--bg);
  background-image: radial-gradient(rgba(0,0,0,0.03) 1px, transparent 0);
  background-size: 16px 16px;

  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
  letter-spacing: -0.01em;
}

/* =========================================================
   LAYOUT
========================================================= */

.container {
  max-width: 980px;
  margin: 28px auto;
  padding: 0 16px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 10px 0;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 820px) {
  .grid { grid-template-columns: 1fr; }
}

/* =========================================================
   CARDS
========================================================= */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.04);
  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

.card:hover {
  border-color: #d7dad6;
  box-shadow: 0 10px 28px rgba(0,0,0,0.06);
}

/* =========================================================
   TYPOGRAPHY
========================================================= */

h1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 16px;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.3;
  margin: 0 0 12px;
}

h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 8px;
}

.muted {
  color: var(--text-muted);
  font-size: 14px;
}

a {
  color: inherit;
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* =========================================================
   FORMS
========================================================= */

input,
select,
textarea {
  font-family: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
}

input,
textarea {
  width: 100%;
  max-width: 520px;
}

textarea { resize: vertical; }

input::placeholder,
textarea::placeholder {
  color: var(--text-hint);
}

/* hover */
input:hover,
select:hover,
textarea:hover {
  border-color: #d0d4d0;
}

/* focus */
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(58,111,106,0.15);
  background-color: #ffffff;
}

/* =========================================================
   BUTTONS
========================================================= */

button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  font-weight: 500;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease;
}

button:hover {
  background: #345f5a;
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

button:active {
  transform: translateY(1px);
  box-shadow: 0 3px 8px rgba(0,0,0,0.16);
}

button.ghost {
  background: transparent;
  color: var(--accent);
}

button.ghost:hover {
  background: var(--accent-soft);
  box-shadow: none;
}

button.danger {
  background: var(--danger);
}
button.danger:hover {
  background: #9f3f2c;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none !important;
}

/* =========================================================
   CHECKBOXES
========================================================= */

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* =========================================================
   CHECKLIST / EDITOR STYLING
========================================================= */

#editor.card { padding: 18px; padding-bottom: 22px; }

#editor details.card {
  padding: 0;
  overflow: hidden;
  border-radius: calc(var(--radius) + 2px);
}

#editor details.card + details.card { margin-top: 12px; }

/* Section header */
#editor summary {
  list-style: none;
  padding: 14px 16px;
  background: linear-gradient(180deg, #ffffff, #fbfbfa);
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 42px;
}
#editor summary::-webkit-details-marker { display: none; }

#editor summary::after {
  content: "►";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  font-size: 18px;
  color: var(--text-muted);
  transition: transform 0.15s ease, color 0.15s ease;
}

#editor details:not([open]) summary::after { transform: translateY(-50%) rotate(0deg); }
#editor summary:hover::after { color: var(--accent); }

/* Section body */
#editor details.card > div {
  padding: 12px 12px 14px;
  background: #ffffff;
}

/* Checklist item row (no card look) */
#editor details.card > div > .card {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 10px 10px;
  border-radius: 12px;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}
#editor details.card > div > .card:hover { background: var(--bg-soft); }

/* Item text */
#editor label.row { margin: 0; gap: 10px; }
#editor label.row strong {
  font-weight: 550;
  font-size: 14px;
  line-height: 1.35;
  cursor: pointer;
}

/* COMPLETED STATE */
#editor input[type="checkbox"]:checked + div { opacity: 0.55; }
#editor input[type="checkbox"]:checked + div strong { text-decoration: line-through; }

/* Indented items visual guide */
#editor details.card > div > .card[style*="margin-left"] { position: relative; }
#editor details.card > div > .card[style*="margin-left"]::before {
  content: "";
  position: absolute;
  left: -10px;
  top: 12px;
  bottom: 12px;
  width: 2px;
  border-radius: 2px;
  background: rgba(58,111,106,0.14);
}

/* Notes */
#editor textarea {
  margin-top: 8px;
  max-width: none;
  width: 100%;
  font-size: 14px;
  line-height: 1.45;
  box-sizing: border-box;
}

/* Note button */
#editor button.ghost[data-toggle-note] {
  padding: 8px 10px;
  border-radius: 10px;
  font-weight: 600;
}

/* =========================================================
   MISC
========================================================= */

hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }

/* Sticky save bar */
.sticky-actions {
  position: sticky;
  bottom: 12px;
  z-index: 20;

  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;

  padding: 12px;
  margin-top: 14px;

  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.10);
  backdrop-filter: blur(8px);
}

.sticky-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 20px;
}

.save-status { font-size: 13px; color: var(--text-muted); }
.save-status.dirty { color: var(--danger); }
.save-status.saved { color: var(--accent); }

/* ---------- Modal + Toast UI ---------- */

.ui-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.42);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  z-index: 9999;
}
.ui-backdrop.show { display: flex; }

.ui-modal {
  width: min(560px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 22px 70px rgba(0,0,0,0.25);
  overflow: hidden;
  transform: translateY(6px);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.ui-backdrop.show .ui-modal { transform: translateY(0); opacity: 1; }

.ui-modal-head {
  padding: 14px 16px;
  background: linear-gradient(180deg, #ffffff, #fbfbfa);
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.ui-modal-title { font-weight: 650; font-size: 16px; margin: 0; }

.ui-modal-body { padding: 14px 16px 6px; color: var(--text); }
.ui-modal-body p {
  margin: 0 0 10px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
}

.ui-modal-actions {
  padding: 12px 16px 16px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.ui-badge {
  font-size: 12px;
  font-weight: 650;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-muted);
}
.ui-badge.danger {
  border-color: rgba(180, 83, 60, 0.35);
  background: rgba(180, 83, 60, 0.10);
  color: var(--danger);
}

/* Toasts */
.ui-toasts {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none; /* clicks pass through container */
}

.ui-toast {
  width: min(360px, calc(100vw - 28px));
  background: rgba(255,255,255,0.92);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 16px 50px rgba(0,0,0,0.16);
  backdrop-filter: blur(8px);
  padding: 10px 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: auto;
}
.ui-toast.show { opacity: 1; transform: translateY(0); }

.ui-toast strong {
  font-size: 13px;
  font-weight: 700;
  display: block;
  line-height: 1.2;
}

.ui-toast .muted { margin-top: 2px; font-size: 13px; }

.ui-toast .x {
  margin-left: auto;
  background: transparent;
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 10px;
}
.ui-toast .x:hover { background: var(--bg-soft); color: var(--text); }

.ui-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  margin-top: 4px;
  background: var(--accent);
}
.ui-dot.danger { background: var(--danger); }

/* ===== Auth page layout ===== */
.container.auth {
  max-width: 980px;
  margin: 28px auto;
  padding: 0 16px 32px;
}

.auth-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 12px 0 16px;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 12px;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 6px;
  box-shadow: 0 10px 24px rgba(0,0,0,0.06);
}

.brand-name {
  font-weight: 800;
  letter-spacing: -0.02em;
  font-size: 16px;
  line-height: 1.15;
}

.brand-sub {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 2px;
}

.auth-meta { font-size: 13px; }

.auth-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 14px;
  margin-top: 6px;
}

@media (max-width: 860px) {
  .auth-grid { grid-template-columns: 1fr; }
  .auth-meta { display:none; }
}

/* Cards */
.auth-card, .auth-side {
  padding: 16px;
}

.auth-title {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

.auth-desc {
  margin: 8px 0 14px;
  font-size: 14px;
}

/* Fields */
.field { display: block; margin-top: 10px; }
.label { display:block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }

.auth-actions { margin-top: 12px; }
.btn-wide { min-width: 220px; }

.auth-help {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.auth-side-title {
  margin: 0;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.auth-list {
  margin: 10px 0 0;
  padding-left: 16px;
  color: var(--text);
}

.auth-list li {
  margin: 8px 0;
  color: var(--text-muted);
}
.auth-list li strong { color: var(--text); }

.auth-divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

.auth-mini { font-size: 13px; }

.auth-foot {
  margin-top: 14px;
  font-size: 12px;
  text-align: center;
}

/* Make inputs feel more premium on auth */
.container.auth input {
  max-width: 100%;
  box-sizing: border-box;
}
.card .note-meta {
  font-size: 0.6rem;
  color: var(--text-hint);
}

nav.nav a {
  text-decoration: none;
  background: var(--text);
  padding: 5px 12px;
  border-radius: 10px;
  color: white;
}

#clList .card {
  margin-bottom: 5px;
}

.quota{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  margin: 6px 0 10px;
  font-size: 13px;
  color: var(--text-muted);
}
.quota strong{ color: var(--text); font-weight: 700; }
.quota .dot{ color: var(--text-hint); }