:root {
  --paper: #faf7f2;
  --paper-2: #f2ede4;
  --card: #ffffff;
  --ink: #24211c;
  --ink-soft: #6b6459;
  --line: #e6ddd0;
  --coral: #ff6a4d;
  --coral-dark: #e2472b;
  --indigo: #5b57d9;
  --teal: #12a594;
  --amber: #d98a12;
  --danger: #d64545;
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over the display rules below (.modal-backdrop,
   .add-btn, .lock-banner, etc. all set `display`, which otherwise overrides the
   browser's default `[hidden] { display: none }`). */
[hidden] { display: none !important; }

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

body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 4rem 1.5rem 3rem;
}

header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

header h1 {
  font-size: clamp(2rem, 5vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.25rem;
}

header p { margin: 0; color: var(--ink-soft); font-size: 1.05rem; }

.key-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.key-btn:hover {
  color: var(--coral-dark);
  border-color: var(--coral);
  transform: translateY(-2px);
  box-shadow: 0 10px 22px -12px rgba(226, 71, 43, 0.5);
}
.key-btn.unlocked {
  color: white;
  background: linear-gradient(155deg, var(--teal), #0c7d70);
  border-color: transparent;
}

.lock-banner {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--teal);
  background: rgba(18, 165, 148, 0.1);
  border: 1px solid rgba(18, 165, 148, 0.25);
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1.25rem;
}
.lock-banner .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--teal);
}
.link-btn {
  border: none; background: none; padding: 0;
  color: var(--teal); font: inherit; cursor: pointer;
  text-decoration: underline;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  box-shadow: 0 1px 2px rgba(36, 33, 28, 0.05);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

thead th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

th.num, td.num { text-align: right; }
.actions-col { width: 1%; }

tbody td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--paper-2);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--paper); }

td.name { font-weight: 600; white-space: normal; min-width: 12rem; }
td.due { color: var(--ink-soft); }

.pill {
  display: inline-block;
  min-width: 2.4rem;
  text-align: center;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.pill.days   { background: rgba(91, 87, 217, 0.12);  color: var(--indigo); }
.pill.work   { background: rgba(255, 106, 77, 0.14); color: var(--coral-dark); }
.pill.ooo    { background: var(--paper-2);           color: var(--ink-soft); }
.pill.net    { background: rgba(18, 165, 148, 0.14); color: var(--teal); }
.pill.past   { background: rgba(214, 69, 69, 0.12);  color: var(--danger); }

.row-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }
.icon-btn {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink-soft);
  border-radius: 9px;
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-soft); }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }

.empty { color: var(--ink-soft); text-align: center; padding: 2.5rem 1rem; }

.add-btn {
  margin-top: 1.25rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px dashed var(--line);
  background: var(--card);
  color: var(--ink-soft);
  padding: 0.7rem 1.2rem;
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.add-btn:hover { color: var(--coral-dark); border-color: var(--coral); }

footer {
  margin-top: 3rem;
  font-size: 0.9rem;
}
footer a {
  color: var(--ink-soft);
  text-decoration: none;
}
footer a:hover { color: var(--ink); }

/* --- modals --- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(36, 33, 28, 0.4);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  /* Scrollable + top-aligned so a tall modal (or a short screen / on-screen
     keyboard) can never push the buttons off-screen — everything stays reachable. */
  overflow-y: auto;
  padding: max(1.5rem, 6vh) 1.5rem 1.5rem;
  z-index: 50;
}
.modal {
  position: relative;
  background: var(--card);
  border-radius: 18px;
  padding: 1.75rem;
  width: 100%;
  max-width: 26rem;
  margin: auto;
  box-shadow: 0 24px 60px -20px rgba(36, 33, 28, 0.4);
}
.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  border-radius: 9px;
  color: var(--ink-soft);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}
.modal-close:hover { background: var(--paper-2); color: var(--ink); }
.modal-key {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 14px;
  background: linear-gradient(155deg, var(--coral), var(--coral-dark));
  color: white;
  margin-bottom: 1rem;
}
.modal h2 { margin: 0 0 0.4rem; font-size: 1.3rem; letter-spacing: -0.01em; }
.modal .muted { margin: 0 0 1.25rem; color: var(--ink-soft); font-size: 0.9rem; }

.modal label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 0.9rem;
}
.modal input {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  color: var(--ink);
  background: var(--paper);
}
.modal input:focus {
  outline: none;
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(255, 106, 77, 0.15);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.btn {
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1.1rem;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: linear-gradient(155deg, var(--coral), var(--coral-dark)); color: white; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: var(--paper-2); color: var(--ink-soft); }
.btn.ghost:hover { color: var(--ink); }

.error { color: var(--danger); font-size: 0.85rem; margin: 0 0 0.75rem; }

@media (max-width: 560px) {
  .wrap { padding: 3rem 1rem 2.5rem; }
}
