/* Duefolio — Study Desk Index-Card Stack theme */

* { box-sizing: border-box; }

:root {
  --accent: #e56b4a;
  --primary: #2f4a6d;
  --secondary: #f2e3c6;
  --paper: #f7ecd7;
  --paper-deep: #efdfc2;
  --card-face: #fffdf6;
  --line: #e0d2b4;
  --edge: #d9c49a;
  --ink: #33302a;
  --muted: #8a7f6a;
  --danger: #b3423f;
  --cobalt: #2f4a6d;
  --tangerine: #e56b4a;
  --sage: #6d8f6d;
  --rose: #c96a7c;
  --nav-h: 96px;
  --radius: 12px;
}

html, body { margin: 0; padding: 0; }

body {
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--paper);
  background-image: repeating-linear-gradient(
    to bottom, transparent 0 3px, rgba(47, 74, 109, 0.03) 3px 4px);
  color: var(--ink);
  min-height: 100vh;
  padding-top: env(safe-area-inset-top);
  -webkit-font-smoothing: antialiased;
}

.desk { max-width: 520px; margin: 0 auto; }

#panels {
  padding: 18px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 26px);
}

/* ---------- Panels ---------- */
.panel { display: none; }
.panel.is-active { display: block; animation: settle 0.18s ease-out; }
@keyframes settle {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}

.panel-head {
  padding-bottom: 10px;
  margin-bottom: 16px;
  border-bottom: 2px solid rgba(47, 74, 109, 0.16);
}
.panel-title {
  margin: 0;
  font-size: 1.45rem;
  letter-spacing: 0.5px;
  color: var(--primary);
}
.panel-sub { margin: 2px 0 0; font-size: 0.85rem; color: var(--muted); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Focus ---------- */
.focus-body { display: flex; gap: 12px; align-items: stretch; }

.rail {
  display: flex; flex-direction: column; gap: 8px;
  width: 46px; flex: 0 0 auto;
}
.rail-tab {
  writing-mode: vertical-rl;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.5px;
  color: var(--primary);
  background: var(--card-face);
  border: 1px solid var(--edge);
  border-left: 5px solid var(--tab-color, var(--primary));
  border-radius: 0 9px 9px 0;
  padding: 10px 2px;
  max-height: 128px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  cursor: pointer;
}
.rail-tab:active { background: var(--secondary); }

.focus-main { flex: 1; display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.counter-wrap { display: flex; align-items: center; gap: 14px; }
.counter {
  flex: 0 0 auto;
  width: 88px; height: 88px; border-radius: 50%;
  background: var(--secondary);
  border: 3px solid var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem; font-weight: 800; color: var(--primary);
}
.counter-label {
  margin: 0;
  font-size: 0.8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); line-height: 1.4;
}

.add-strip {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--accent); color: #fff;
  border: none; border-radius: var(--radius);
  padding: 16px 12px;
  font-size: 1rem; font-weight: 700; letter-spacing: 0.3px;
  box-shadow: 0 2px 0 #b34f34;
  cursor: pointer;
}
.add-strip:active { transform: translateY(1px); box-shadow: none; }
.pencil {
  width: 20px; height: 20px; background: #fff;
  clip-path: polygon(0 28%, 72% 28%, 72% 12%, 100% 50%, 72% 88%, 72% 72%, 0 72%);
}

.pinned-label {
  margin: 0 0 8px;
  font-size: 0.7rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--muted);
}

/* ---------- Index cards ---------- */
.card-stack { display: flex; flex-direction: column; gap: 12px; }

.card {
  position: relative;
  background: var(--card-face);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 2px 4px rgba(51, 48, 42, 0.08);
  overflow: hidden;
}
.strip { position: absolute; left: 0; top: 0; bottom: 0; width: 7px; }

.row-main {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 12px 4px 20px;
}
.stamp {
  flex: 0 0 auto;
  width: 46px; height: 46px; border-radius: 50%;
  border: 2px solid var(--primary);
  background: var(--secondary);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; line-height: 1;
}
.stamp-mon { font-size: 0.55rem; font-weight: 800; letter-spacing: 1px; color: var(--primary); }
.stamp-day { font-size: 1.05rem; font-weight: 800; color: var(--ink); }

.card-body { min-width: 0; }
.card-title {
  margin: 0; font-size: 1rem; font-weight: 600; color: var(--ink);
  overflow-wrap: anywhere;
}
.card-course {
  margin: 3px 0 0;
  font-size: 0.75rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.6px;
}
.card-due { margin: 2px 0 0; font-size: 0.8rem; color: var(--muted); }
.card-due .overdue { color: var(--danger); font-weight: 700; }

.card-actions {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 6px 12px 12px 20px;
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--edge);
  background: #faf3e2;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem; font-weight: 600;
  color: var(--primary);
  cursor: pointer;
}
.pill:active { background: var(--secondary); }
.pill-danger { color: var(--danger); border-color: #d8a49a; }

.dot { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; }
.dot-solid { background: var(--primary); }
.dot-open { border: 2px solid var(--primary); background: transparent; }

.card.is-done .card-title,
.card.is-done .card-due { color: var(--muted); }
.card.is-done .stamp { opacity: 0.55; }

/* ---------- Empty states ---------- */
.empty {
  border: 1.5px dashed #cbb384;
  border-radius: var(--radius);
  padding: 24px 16px;
  text-align: center;
  color: var(--muted);
  background: rgba(255, 253, 246, 0.6);
  font-size: 0.88rem;
}
.empty strong {
  display: block; margin-bottom: 4px;
  color: var(--primary); font-size: 0.95rem;
}

/* ---------- Capture notebook ---------- */
.notebook {
  position: relative;
  background: var(--card-face);
  background-image: repeating-linear-gradient(
    to bottom, transparent 0 27px, rgba(47, 74, 109, 0.09) 27px 28px);
  border: 1px solid var(--line);
  border-radius: 4px 14px 14px 4px;
  padding: 18px 16px 18px 36px;
  margin: 0;
}
.notebook::before {
  content: "";
  position: absolute; left: 13px; top: 16px; bottom: 16px; width: 12px;
  background-image: radial-gradient(circle at 6px 6px,
    var(--paper) 0 3px, #b8a37e 3px 4px, transparent 4.5px);
  background-size: 12px 26px;
  background-repeat: repeat-y;
}

.field { margin-bottom: 15px; min-width: 0; }
.field-label {
  display: block;
  font-size: 0.72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--primary); margin-bottom: 6px;
}
.field label {
  display: block;
  font-size: 0.72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--primary); margin-bottom: 6px;
}
.field input {
  width: 100%;
  font-family: inherit;
  font-size: 16px; /* avoids iOS zoom-on-focus */
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--edge);
  border-radius: 10px;
  padding: 12px;
}
.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: var(--accent);
}
.field-error {
  margin: 6px 0 0;
  font-size: 0.78rem; font-weight: 600;
  color: var(--danger);
}

.toggle-done {
  display: inline-flex; align-items: center; gap: 10px;
  border: 1px solid var(--edge);
  background: #faf3e2;
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 0.9rem; font-weight: 700;
  color: var(--primary);
  cursor: pointer;
}

.btn-primary {
  width: 100%;
  background: var(--primary); color: #fff;
  border: none; border-radius: var(--radius);
  padding: 14px; font-size: 1rem; font-weight: 700;
  cursor: pointer;
}
.btn-primary:active { background: #24395a; }
.btn-ghost {
  width: 100%; margin-top: 10px;
  background: transparent; color: var(--primary);
  border: 1px solid var(--edge); border-radius: var(--radius);
  padding: 12px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer;
}
.btn-danger {
  width: 100%; margin-top: 10px;
  background: transparent; color: var(--danger);
  border: 1px solid #d8a49a; border-radius: var(--radius);
  padding: 12px; font-size: 0.95rem; font-weight: 600;
  cursor: pointer;
}

/* ---------- Find ---------- */
#find-input { margin-bottom: 12px; }
#panel-find > .field { margin-bottom: 12px; }

.course-tabs {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 2px 0 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.course-tabs::-webkit-scrollbar { display: none; }

.chip {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--edge);
  background: #faf3e2;
  border-radius: 999px;
  padding: 7px 13px;
  font-size: 0.8rem; font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  white-space: nowrap;
}
.chip .dot { width: 10px; height: 10px; background: var(--chip-color, var(--primary)); }
.chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.chip.is-active .dot { background: #fff; }

/* ---------- Binder-clip bottom tabs ---------- */
.clipnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center; gap: 7px;
  padding: 0 12px calc(env(safe-area-inset-bottom) + 0px);
  background: var(--paper-deep);
  border-top: 1px solid #d8c69b;
}
.clip {
  flex: 1 1 0; max-width: 132px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 11px 0 9px;
  background: #efe2c6;
  border: 1px solid #cbb384;
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  transform: translateY(4px);
  box-shadow: none;
  color: var(--muted);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.clip-hole {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2.5px solid var(--primary);
  background: transparent;
}
.clip-label { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.4px; }

.clip.is-active {
  transform: translateY(-7px);
  background: #fff9ec;
  color: var(--accent);
  box-shadow: 0 9px 14px rgba(51, 48, 42, 0.3);
}
.clip.is-active .clip-hole { border-color: var(--accent); }

@media (min-width: 521px) {
  .clipnav {
    left: 50%; transform: translateX(-50%);
    width: 520px; max-width: 100%;
    border-left: 1px solid #d8c69b;
    border-right: 1px solid #d8c69b;
  }
}
