* {
  box-sizing: border-box;
}

body.modal-open {
  overflow: hidden;
}

/* 1. Header Area */
.top-bar {
  grid-area: header;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.025), rgba(255, 255, 255, 0)),
    rgba(20, 19, 23, 0.96);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: 0 1px 0 rgba(216, 167, 58, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
}

.control-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  line-height: 1;
  text-transform: uppercase;
}

.search-group {
  align-items: flex-end;
  flex: 1 1 560px;
  max-width: 780px;
}

.search-input-field {
  flex: 1 1 260px;
}

select,
input[type="search"],
input[type="text"] {
  background: rgba(8, 8, 10, 0.74);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035);
}

.icon-btn {
  background: transparent;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.2s;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* 2. Left Navigation Sidebar */
.nav-tab {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 12px 0;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.2s;
  position: relative;
}

/* 3. Main Content Area */
.content-area {
  grid-area: main;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.018), transparent 16rem),
    var(--bg-deep);
  overflow-y: auto;
  padding: 2rem;
  position: relative;
}

.tab-view {
  display: none;
  max-width: 1000px;
  margin: 0 auto;
  animation: fadeIn 0.2s;
}

.home-hero-header,
.home-latest-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.home-hero-header {
  align-items: flex-start;
}

.home-hero-copy {
  margin: 0;
  line-height: 1.6;
}

.home-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.home-checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.home-checklist-copy {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.home-checklist-title {
  font-weight: 600;
  color: var(--text-primary);
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.view-header h2 {
  font-family: var(--font-serif);
  font-size: 2rem;
  border-bottom: 0;
  padding-bottom: 0.5rem;
  color: var(--text-primary);
}

.quest-filter-group {
  min-width: 0;
}

.quest-workbench-toolbar input[type="search"] {
  width: 100%;
}

.quest-search-field {
  min-width: 0;
}

.quest-journal-meta {
  margin: 0 0 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.quest-dashboard-metric {
  min-width: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.7rem;
  background: rgba(255, 255, 255, 0.035);
}

.quest-dashboard-metric strong {
  display: block;
  color: var(--text-primary);
  font-size: 1.1rem;
  line-height: 1.1;
}

.quest-dashboard-metric span,
.quest-dashboard-metric small {
  display: block;
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.72rem;
  line-height: 1.3;
  text-transform: uppercase;
  letter-spacing: 0;
}

.quest-dashboard-metric small {
  color: var(--text-secondary);
  text-transform: none;
}

/*
 * The Weave editorial UI
 *
 * This layer deliberately replaces the prototype's dashboard-first presentation
 * while leaving its role-aware data and interaction contracts intact.
 */

html {
  background: var(--weave-canvas);
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  height: auto;
  overflow-x: hidden;
  overflow-y: auto;
  background:
    radial-gradient(circle at 78% -8%, rgba(193, 154, 85, 0.13), transparent 34rem),
    radial-gradient(circle at 12% 22%, rgba(49, 73, 67, 0.035), transparent 28rem),
    linear-gradient(180deg, #fbf8f0 0, var(--weave-canvas) 25rem);
  color: var(--weave-ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea,
summary {
  -webkit-tap-highlight-color: transparent;
}

:focus-visible:not(.email-chips input, .recap-review-reader [contenteditable], .recap-link-library input, .recap-cast-editor input) {
  outline: 2px solid var(--weave-color-action) !important;
  outline-offset: 3px;
}

.hidden {
  display: none !important;
}

.campaign-role-pending #dmAdminBtn,
.campaign-role-pending #settingsView,
.campaign-role-pending #newSessionBtn,
.campaign-role-pending #startRunBtn,
.campaign-role-pending #editSessionBtn,
.campaign-role-pending #exportSessionBtn,
.campaign-role-pending #deleteSessionBtn,
.campaign-role-pending #sessionProductionTools,
.campaign-role-pending #evidenceSections,
.campaign-role-pending #miniRunStatusCard {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  z-index: 3000;
  top: 0.75rem;
  left: 0.75rem;
  transform: translateY(-180%);
  border-radius: var(--radius-md);
  background: var(--weave-paper);
  color: var(--weave-wax);
  padding: 0.75rem 1rem;
  box-shadow: var(--weave-shadow);
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

/* Shell */

.app-container {
  display: grid;
  grid-template-areas:
    "header header"
    "nav main";
  grid-template-columns: 216px minmax(0, 1fr);
  grid-template-rows: 72px minmax(calc(100vh - 72px), auto);
  width: 100%;
  min-height: 100vh;
  height: auto;
}

.main-layout {
  display: contents;
}

.top-bar {
  position: sticky;
  z-index: 100;
  top: 0;
  grid-area: header;
  display: grid;
  grid-template-columns: 216px minmax(360px, 1fr) auto;
  align-items: center;
  min-height: 72px;
  padding: 0 1.25rem 0 1.5rem;
  border: 0;
  border-bottom: 1px solid rgba(185, 145, 82, 0.28);
  background:
    linear-gradient(90deg, rgba(185, 145, 82, 0.08), transparent 32%),
    rgba(38, 57, 54, 0.98);
  box-shadow: 0 4px 18px rgba(27, 36, 34, 0.16);
}

.brand h1,
.brand-lockup h1 {
  margin: 0;
  color: #fffaf0;
  font-family: var(--font-serif);
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: 0.01em;
}

.search-group {
  max-width: 640px;
}

.top-bar .search-group {
  display: none;
}

body[data-view="sessions"] .top-bar .search-group {
  display: flex;
}

.top-bar select,
.top-bar input[type="search"],
.top-bar input[type="text"] {
  min-height: 40px;
  border-color: rgba(255, 250, 240, 0.2);
  background: rgba(16, 28, 26, 0.46);
  color: #fffaf0;
  box-shadow: none;
}

.top-bar input::placeholder {
  color: #aaa99f;
}

.top-bar .icon-btn {
  min-width: 42px;
  min-height: 42px;
  color: #ddd6c7;
}

.top-bar .icon-btn:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #fffaf0;
}

.top-bar :focus-visible,
#landingScreen :focus-visible {
  outline-color: #80602a !important;
}

.user-controls {
  justify-self: end;
}

.left-nav {
  position: sticky;
  z-index: 40;
  top: 72px;
  grid-area: nav;
  align-self: start;
  display: flex;
  height: calc(100vh - 72px);
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
  overflow-y: auto;
  padding: 1.5rem 1rem;
  border: 0;
  border-right: 1px solid rgba(185, 145, 82, 0.18);
  background:
    linear-gradient(180deg, rgba(185, 145, 82, 0.075), transparent 16rem),
    var(--weave-pine-deep);
}

.nav-tab {
  display: flex;
  width: 100%;
  min-height: 48px;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0.8rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #bcbeb5;
  font-size: 0.92rem;
  font-weight: 650;
  text-align: left;
}

.nav-tab .icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.nav-tab:hover {
  border-color: rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.055);
  color: #fffaf0;
  transform: none;
}

.player-shell .nav-tab.player-primary {
  color: #bcbeb5;
}

.player-shell .nav-tab.player-primary.active,
.player-shell .nav-tab.player-primary[aria-current="page"] {
  color: #fffaf0;
}

.right-sidebar {
  display: none !important;
}

.content-area {
  grid-area: main;
  min-width: 0;
  overflow: visible;
  padding: clamp(1.5rem, 3vw, 3.5rem) clamp(1.25rem, 4vw, 4.5rem) 5rem;
  background: transparent;
}

.tab-view {
  max-width: 1280px;
  margin: 0 auto;
  animation: weave-enter 180ms ease-out;
}

.tab-view.active {
  display: block;
}

@keyframes weave-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  display: flex;
  min-height: auto;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.5rem;
  margin: 0 0 1.75rem;
  padding: 0 0 1rem;
}

.view-header h2 {
  margin: 0;
  color: var(--weave-ink);
  font-family: var(--font-serif);
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.05;
}

.view-header h2:focus-visible {
  outline: 0 !important;
  box-shadow: 0 3px 0 rgba(185, 145, 82, 0.72);
}

.view-subtitle {
  max-width: 68ch;
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.eyebrow,
.section-eyebrow {
  margin: 0 0 0.45rem;
  color: var(--weave-wax);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.meta {
  color: var(--weave-muted);
}

/* Controls */

select,
input[type="search"],
input[type="text"],
input[type="email"],
input[type="url"],
input[type="date"],
input[type="time"],
input[type="number"],
textarea {
  min-height: 44px;
  border: 1px solid #cfc4b1;
  border-radius: 7px;
  background: #fffefb;
  color: var(--weave-ink);
  box-shadow: inset 0 1px 2px rgba(52, 43, 31, 0.035);
}

textarea {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.55;
  resize: vertical;
}

select:focus,
input:focus,
textarea:focus {
  border-color: var(--weave-wax);
  outline: 2px solid #80602a;
}

.control-label {
  color: var(--weave-muted);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.primary-btn,
.btn-secondary,
button.primary-btn,
button.btn-secondary {
  min-height: 44px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.005em;
  box-shadow: none;
}

.primary-btn,
button.primary-btn {
  border: 1px solid var(--weave-wax);
  background: var(--weave-wax);
  color: #fffdf8;
  padding: 0.5rem 1rem;
}

.primary-btn:hover,
button.primary-btn:hover {
  border-color: #662522;
  background: #662522;
  opacity: 1;
}

.btn-secondary,
button.btn-secondary {
  border: 1px solid #bfb29d;
  background: transparent;
  color: var(--weave-pine-deep);
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.btn-secondary:hover,
button.btn-secondary:hover {
  border-color: var(--weave-pine);
  background: rgba(53, 75, 71, 0.065);
  color: var(--weave-pine-deep);
  transform: translateY(-1px);
}

.primary-btn.small {
  min-height: 36px;
  padding: 0.4rem 0.9rem;
  font-size: 0.85rem;
}

.btn-secondary.small {
  min-height: 36px;
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
}

.tag {
  border: 1px solid rgba(53, 75, 71, 0.14);
  border-radius: 999px;
  background: rgba(53, 75, 71, 0.07);
  color: var(--weave-pine-deep);
  font-size: 0.72rem;
  font-weight: 600;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border: 1px solid rgba(38, 57, 54, 0.24);
  border-radius: 12px;
  background: #ece8de;
  color: #263936;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-pill.completed,
.status-pill.complete,
.status-pill.ready,
.status-pill.published,
.status-pill.resolved {
  border-color: #a9c3ad;
  background: #e1ece2;
  color: #23482d;
}

.status-pill.warning,
.status-pill.partial,
.status-pill.queued,
.status-pill.running,
.status-pill.processing,
.status-pill.proposed {
  border-color: #d1ba82;
  background: #f3e8cd;
  color: #60450d;
}

.status-pill.active {
  border-color: #b2c2d7;
  background: #e1e9f4;
  color: #263f63;
}

.status-pill.failed,
.status-pill.blocked,
.status-pill.danger {
  border-color: #dab0ad;
  background: #f5dfdd;
  color: #7d2422;
}

.status-pill.abandoned,
.status-pill.idle {
  border-color: #c9c2b7;
  background: #e8e4dc;
  color: #4f4a44;
}

.landing-screen { position: fixed; inset: 0; z-index: 1000; overflow-y: auto; }

/* Premium editorial shell and component finish */

.app-container,
.app-container.session-reading-mode {
  grid-template-columns: 228px minmax(0, 1fr);
  grid-template-rows: var(--shell-header-height) minmax(calc(100vh - var(--shell-header-height)), auto);
}

.top-bar {
  grid-template-columns: 228px minmax(420px, 1fr) auto;
  min-height: var(--shell-header-height);
  padding: 0 1.5rem 0 1.65rem;
  border-bottom-color: rgba(193, 154, 85, 0.34);
  background:
    linear-gradient(90deg, rgba(193, 154, 85, 0.1), transparent 24%),
    linear-gradient(180deg, var(--weave-pine), var(--weave-pine-deep));
  box-shadow: 0 8px 26px rgba(23, 41, 37, 0.17);
}

.brand {
  gap: 0.82rem;
}

.left-nav {
  top: var(--shell-header-height);
  height: calc(100vh - var(--shell-header-height));
  gap: 0.22rem;
  padding: 1.75rem 1rem;
  border-right-color: rgba(193, 154, 85, 0.2);
  background:
    radial-gradient(circle at 0 0, rgba(193, 154, 85, 0.12), transparent 15rem),
    linear-gradient(180deg, var(--weave-pine-deep), var(--weave-pine-black));
}

.nav-tab {
  min-height: 50px;
  gap: 0.9rem;
  padding: 0.74rem 0.82rem;
  border-radius: var(--radius-sm);
  color: var(--weave-inverse-muted);
  font-weight: 600;
}

.nav-tab .icon {
  width: 22px;
  height: 22px;
  flex-basis: 22px;
}

.nav-tab .label {
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  text-transform: none;
}

.nav-tab:hover {
  border-color: transparent;
  background: rgba(255, 255, 255, 0.045);
}

.nav-tab.active,
.nav-tab[aria-current="page"] {
  border-color: transparent;
  background: linear-gradient(90deg, rgba(193, 154, 85, 0.17), rgba(193, 154, 85, 0.055));
  color: var(--weave-inverse);
  box-shadow: inset 2px 0 0 var(--weave-gold-bright);
}

.content-area {
  padding: 2rem clamp(1.5rem, 3vw, 3rem) 6rem;
}

.view-header {
  position: relative;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom-color: rgba(135, 101, 47, 0.23);
}

.view-header h2 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 3vw, 2.75rem);
  font-weight: 500;
  letter-spacing: -0.035em;
}

.view-header h2::after {
  content: "";
  display: block;
  width: clamp(5.5rem, 11vw, 9rem);
  height: 1px;
  margin-top: 0.7rem;
  background: linear-gradient(90deg, var(--weave-gold), transparent);
}

.view-subtitle {
  max-width: 62ch;
  margin-top: 0.45rem;
  color: var(--weave-muted);
  font-size: 0.98rem;
  line-height: 1.55;
}

.eyebrow,
.section-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
}

select,
input[type="search"],
input[type="text"],
input[type="email"],
input[type="url"],
input[type="date"],
input[type="time"],
input[type="number"],
textarea {
  border-color: var(--weave-rule-strong);
  background: var(--weave-paper-raised);
  box-shadow: inset 0 1px 2px rgba(52, 43, 31, 0.025);
}

.primary-btn,
.btn-secondary,
button.primary-btn,
button.btn-secondary {
  border-radius: var(--radius-md);
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease, box-shadow 150ms ease, transform 150ms ease;
}

.primary-btn,
button.primary-btn {
  border-color: var(--weave-wax);
  background: var(--weave-color-action);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16), 0 5px 14px rgba(97, 35, 33, 0.14);
}

.primary-btn:hover,
button.primary-btn:hover {
  border-color: var(--weave-wax-deep);
  background: var(--weave-wax-deep);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 7px 18px rgba(97, 35, 33, 0.19);
  transform: translateY(-1px);
}

.btn-secondary,
button.btn-secondary {
  border-color: var(--weave-rule-strong);
  background: rgba(255, 254, 250, 0.46);
}

.btn-secondary:hover,
button.btn-secondary:hover {
  border-color: var(--weave-pine);
  background: rgba(49, 73, 67, 0.065);
  box-shadow: 0 4px 12px rgba(52, 43, 31, 0.055);
}

/* Keep session filtering with the archive at every viewport width. */
#headerSessionFilter {
  width: 100%;
  margin: 0 0 1.25rem;
  min-width: 0;
}
#headerSessionFilter .search-input-field,
#headerSessionFilter input { width: 100%; min-width: 0; }
