/* Ardenfall Hub — flat, sharp-edged dark UI.
   Palette: page #0E0E10, surface #151517, raised #1B1B1E, borders #26262B/#3A3A40,
   text #EDEDEF/#9A9AA2, oxblood accent #77282A (fill) / #9E3033 (mark) / #D99A9B (text).
   No radii, no gradients, no shadows.
   The signature is the flat red index mark: h1 underline block, active nav bar, selected row bar. */

* { box-sizing: border-box; }
body {
  font-family: "Segoe UI", system-ui, sans-serif;
  margin: 0;
  background: #0E0E10;
  color: #EDEDEF;
}
::selection { background: #77282A; color: #fff; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0E0E10; }
::-webkit-scrollbar-thumb { background: #33333A; }
::-webkit-scrollbar-thumb:hover { background: #9E3033; }

a, a:visited { color: #D99A9B; }

h1 {
  position: relative;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin: 0 0 1.25rem;
  padding-bottom: 0.6rem;
}
h1::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  width: 2.5rem;
  height: 3px;
  background: #9E3033;
}
h2 { font-size: 1.1rem; font-weight: 600; color: #D99A9B; margin: 1.5rem 0 0.75rem; }

nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  background: #151517;
  color: #EDEDEF;
  border-bottom: 1px solid #26262B;
}
.nav-tools, .nav-user { display: flex; gap: 0.25rem; align-items: center; }
.nav-user { gap: 1rem; }
nav a, nav a:visited { color: #EDEDEF; text-decoration: none; }
.nav-tools a {
  padding: 0.35rem 0.7rem;
  font-size: 0.9rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.nav-tools a:hover { background: #1F1F23; }
.nav-tools a.active {
  background: #1B1B1E;
  color: #fff;
  font-weight: 600;
  box-shadow: inset 0 -2px 0 #9E3033; /* flat index mark, not a shadow */
}
.nav-user a:hover { color: #D99A9B; text-decoration: underline; }
.nav-user { color: #9A9AA2; font-size: 0.9rem; }
.nav-user strong { color: #EDEDEF; }

main {
  max-width: 640px;
  margin: 2rem auto;
  padding: 1.5rem;
  background: #151517;
  border: 1px solid #26262B;
}
.auth-box { max-width: 320px; }
form { display: flex; flex-direction: column; gap: 0.75rem; margin-top: 1rem; }
label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; color: #C9C9CE; position: relative; }

/* Tag autocomplete dropdown, anchored to its label. */
.tag-suggest {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  background: #1A1A1D;
  border: 1px solid #3A3A40;
}
.tag-suggest button {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  padding: 0.4rem 0.6rem;
  background: none;
  border: none;
  color: #EDEDEF;
  text-align: left;
  cursor: pointer;
}
.tag-suggest button:hover { background: #26262B; }
.tag-suggest .tag-count { color: #9A9AA2; font-size: 0.8em; }
input[type=text], input[type=password], input[type=url], input[type=date], input[type=number], textarea, select {
  padding: 0.5rem;
  border: 1px solid #33333A;
  background: #1A1A1D;
  color: #EDEDEF;
  font: inherit;
  transition: border-color 0.15s ease;
}
input[type=text]:focus, input[type=password]:focus, input[type=url]:focus,
input[type=date]:focus, input[type=number]:focus, textarea:focus, select:focus {
  outline: none;
  border-color: #9E3033;
  box-shadow: 0 0 0 1px #9E3033; /* crisp 2px focus ring, no blur */
}
button {
  padding: 0.5rem 0.9rem;
  border: 1px solid #77282A;
  background: #77282A;
  color: #F2F2F2;
  font: inherit;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
button:hover { background: #8F3336; border-color: #8F3336; }
button:active { background: #6A2325; }
button:focus-visible, a:focus-visible { outline: 2px solid #9E3033; outline-offset: 2px; }

table { width: 100%; border-collapse: collapse; margin-top: 1rem; }
th, td { text-align: left; padding: 0.5rem 0.4rem; border-bottom: 1px solid #26262B; }
th {
  color: #9A9AA2;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid #3A3A40;
}
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: #EDEDEF; }
th[data-sort="asc"]::after { content: " \2191"; color: #9E3033; }
th[data-sort="desc"]::after { content: " \2193"; color: #9E3033; }
tbody tr { transition: background-color 0.15s ease; }
tbody tr:hover { background: #1B1B1E; }
.error { color: #FF6B6B; }
.success { color: #6BCF7A; }

main.wide { max-width: none; }

.add-resource { margin-bottom: 1.5rem; }
.add-resource summary { cursor: pointer; font-weight: 600; }

.toolbar { display: flex; gap: 0.75rem; margin: 1rem 0; position: relative; }
.toolbar #search { flex: 1; padding: 0.5rem; border: 1px solid #33333A; background: #1A1A1D; color: #EDEDEF; }

/* Split button: filled primary action + unfilled secondary squished together. */
.split-btn { display: flex; }
.split-btn .split-btn-alt {
  background: none;
  border: 1px solid #77282A;
  border-left: none;
  color: #D99A9B;
}
.split-btn .split-btn-alt:hover { background: #2A1516; }

/* Weekly goal cards. */
.goal-tasks { list-style: none; padding: 0; margin: 0.6rem 0; }
.goal-tasks li { display: flex; align-items: center; gap: 0.5rem; padding: 0.2rem 0; }
.goal-tasks a, .goal-tasks a:visited { color: #EDEDEF; }
.goal-tasks form { margin: 0; }

/* Saved searches panel, toggled from the toolbar. */
#saved-searches { border: 1px solid #26262B; background: #1A1A1D; padding: 0.75rem 1rem; margin-bottom: 1rem; }
#saved-searches[hidden] { display: none; }
.saved-search { display: flex; align-items: center; gap: 0.6rem; margin: 0.3rem 0; }
.saved-search form { margin: 0; }
.saved-search-query { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tag-cloud { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 1rem; }
.tag-chip {
  border: 1px solid #5A2224;
  background: #2A1516;
  color: #D99A9B;
  padding: 0.15rem 0.6rem;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.tag-chip:not(.static):hover { background: #3A1B1D; border-color: #9E3033; }
.tag-chip.static { cursor: default; }

.resource-card {
  border: 1px solid #26262B;
  background: #151517;
  padding: 0.9rem 1rem;
  margin-bottom: 0.75rem;
  transition: border-color 0.15s ease;
}
.resource-card:hover { border-color: #4A4A52; }
.resource-header { display: flex; justify-content: space-between; align-items: center; }
.resource-name, .resource-name:visited { font-weight: 600; font-size: 1.05rem; color: #D99A9B; text-decoration: none; }
.resource-name:hover { text-decoration: underline; }
.resource-desc { margin: 0.4rem 0; color: #C9C9CE; }
.resource-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin: 0.4rem 0; }
.resource-meta { margin: 0; font-size: 0.75rem; color: #9A9AA2; }

.resource-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 0.4rem; }
.resource-actions { display: flex; gap: 0.5rem; margin: 0; }
.resource-actions button, .resource-actions .delete-form { margin: 0; }
.edit-btn, .cancel-edit-btn {
  background: none;
  color: #C9C9CE;
  border: 1px solid #3A3A40;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.edit-btn:hover, .cancel-edit-btn:hover { background: #1B1B1E; border-color: #4A4A52; color: #EDEDEF; }
.delete-btn {
  background: none;
  border: 1px solid #77282A;
  color: #FF8A8C;
  padding: 0.2rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background-color 0.15s ease;
}
.delete-btn:hover { background: #2A1516; }
.edit-form { margin-top: 0.6rem; padding-top: 0.6rem; border-top: 1px solid #26262B; }
.edit-form[hidden] { display: none; }
.choice-new[hidden] { display: none; }
.check-item { list-style: none; }

.home-logo { display: block; width: 96px; max-width: 100%; margin: 0 auto 1.25rem; }

.homepage-content :first-child { margin-top: 0; }
.pencil-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem;
  color: #9A9AA2;
  margin-top: 1rem;
  transition: color 0.15s ease;
}
.pencil-btn:hover { color: #D99A9B; }
.pencil-btn[hidden] { display: none; }

.pin-form, .quick-form { margin: 0; }
.pin-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 0.2rem;
  opacity: 0.35;
  filter: grayscale(1) brightness(1.8);
  transition: opacity 0.15s ease, filter 0.15s ease;
}
.pin-btn.pinned { opacity: 1; filter: none; }
.pin-btn:hover { opacity: 0.7; }

.badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  flex-shrink: 0;
}
.badge-blocked { background: #3A1518; color: #FF7B7D; border: 1px solid #77282A; }

/* Status colors: shared by the table label and the detail-pane select.
   Statuses beyond the defaults fall back to plain text color. */
.status-unstarted { color: #9A9AA2; }
.status-paused { color: #D9A94F; }
.status-waiting-for-feedback { color: #B08AD9; }
.status-canceled { color: #FF7B7D; }
.status-completed { color: #6BCF7A; }
/* Location states. */
.status-planned { color: #9A9AA2; }
.status-in-progress { color: #6BA8DF; }
.status-complete { color: #6BCF7A; }
/* Priority colors: Medium is the neutral default. */
.priority-low { color: #9A9AA2; }
.priority-medium { color: #EDEDEF; }
.priority-high { color: #D9A94F; }
.priority-very-high { color: #FF7B7D; }
.status-label, .priority-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  padding: 0.15rem 0.55rem;
  background: #1B1B1E;
  border: 1px solid #33333A;
  white-space: nowrap;
}
.status-select { padding: 0.25rem 0.4rem; font-size: 0.85rem; }

/* Tasks split view: table on the left, selected task's details on the right. */
/* Detail viewer keeps its ~half-of-1400px width; the list absorbs all extra room. */
.task-split { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 660px); gap: 1.5rem; align-items: start; margin-top: 1rem; }
.task-list { overflow-x: auto; }
/* Desktop split-view pages are viewport-locked: the page itself never scrolls;
   the list and the detail pane each get their own scrollbar when needed. */
@media (min-width: 641px) {
  body:has(.task-split) { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
  body:has(.task-split) main.wide {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* fallback if the non-split content (open add form) grows tall */
    margin: 1rem 2rem;
  }
  body:has(.task-split) main.wide > button[data-toggle] { align-self: flex-start; }
  body:has(.task-split) .task-split { flex: 1; min-height: 0; display: flex; align-items: flex-start; }
  body:has(.task-split) .task-list { flex: 1; min-width: 0; max-height: 100%; overflow-y: auto; }
  body:has(.task-split) .task-detail-pane { flex: 0 1 660px; min-width: 0; max-height: 100%; overflow-y: auto; position: static; }
  .tasks-table { margin-top: 0; }
  .tasks-table th { position: sticky; top: 0; background: #151517; }
}
.tasks-table { min-width: 640px; }
.task-row { cursor: pointer; }
.task-row.selected, .task-row.selected:hover {
  background: #241214;
  box-shadow: inset 2px 0 0 #9E3033; /* flat index mark */
}
.task-detail-pane {
  background: #111114;
  border: 1px solid #26262B;
  padding: 1rem 1.25rem;
  position: sticky;
  top: 1rem;
}
/* While the edit panel is open, hide the read-only preview (meta, description,
   and the links display — the editor has its own Links section). */
.task-detail:has(> .edit-form:not([hidden])) .task-meta,
.task-detail:has(> .edit-form:not([hidden])) .task-desc,
.task-detail:has(> .edit-form:not([hidden])) > .link-section { display: none; }

.task-detail-header { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; }
.task-detail-header h2 { margin: 0; }
.task-meta { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 1.25rem; margin: 1rem 0 0; font-size: 0.9rem; }
.task-meta dt { color: #9A9AA2; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; }
.task-meta dd { margin: 0; }
.task-desc { border-top: 1px solid #26262B; margin-top: 0.9rem; padding-top: 0.9rem; }
.task-desc > :first-child { margin-top: 0; }
.task-desc > :last-child { margin-bottom: 0; }

.link-section { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid #26262B; }
.link-section h3 { font-size: 0.9rem; color: #D99A9B; margin: 0 0 0.5rem; }
.link-group { margin-bottom: 0.5rem; }
.link-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: #1B1B1E;
  border: 1px solid #33333A;
  padding: 0.1rem 0.5rem;
  margin: 0.15rem 0.15rem 0.15rem 0;
  font-size: 0.8rem;
}
.delete-link-form { margin: 0; display: inline; }
.link-chip button {
  background: none;
  border: none;
  color: #FF8A8C;
  cursor: pointer;
  padding: 0 0.2rem;
  font-size: 1rem;
  line-height: 1;
}
/* A div now (staged links post with the edit form), so display:flex is explicit. */
.link-add-form { display: flex; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 0.5rem; position: relative; }
.link-add-form[hidden] { display: none; }
/* Search box shares the row with the relation select. */
.link-add-form .obj-search { flex: 1; min-width: 0; }
/* Breathing room between the links editor and Save/Cancel. */
.link-section + .resource-actions { margin-top: 1.25rem; }
.link-add-form select { min-width: 0; max-width: 100%; }
.hint { color: #9A9AA2; font-size: 0.8rem; }

/* Last so these win over the desktop rules above (same specificity, order matters). */
@media (max-width: 640px) {
  nav { flex-wrap: wrap; gap: 0.5rem; padding: 0.6rem 1rem; }
  .nav-user { flex-wrap: wrap; }
  main, main.wide { margin: 1rem auto; padding: 1rem; max-width: 100%; }
  .edit-btn, .cancel-edit-btn, .delete-btn { padding: 0.4rem 0.8rem; font-size: 0.85rem; }
  /* List-only by default; ?task=N (main.viewing) shows the task standalone instead. */
  .task-split { grid-template-columns: minmax(0, 1fr); }
  .task-detail-pane { display: none; }
  main.viewing .task-list,
  main.viewing .toolbar,
  main.viewing #saved-searches,
  main.viewing [data-toggle="add-root-form"],
  main.viewing #add-root-form { display: none; }
  main.viewing .task-detail-pane { display: block; position: static; }
}
