:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #647069;
  --line: #d9dfdc;
  --panel: #ffffff;
  --wash: #eef3f0;
  --accent: #0f766e;
  --accent-dark: #0b5f59;
  --accent-soft: #e3f4f1;
  --accent-ring: rgba(15, 118, 110, 0.22);
  --warn: #a33b20;
  --ok: #246b3d;
  --shadow-soft: 0 14px 36px rgba(23, 32, 27, 0.08);
  --shadow-button: 0 6px 14px rgba(23, 32, 27, 0.10);
}

body:has(#j1Tab.active) {
  --accent: #0b5f93;
  --accent-dark: #08476f;
  --accent-soft: #e6f1f8;
  --accent-ring: rgba(11, 95, 147, 0.22);
  --wash: #eef5f9;
}

body:has(#j2Tab.active) {
  --accent: #651e18;
  --accent-dark: #4f1712;
  --accent-soft: #f7e9e6;
  --accent-ring: rgba(101, 30, 24, 0.22);
  --wash: #f4efed;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, color-mix(in srgb, var(--accent) 10%, transparent), transparent 34rem),
    var(--wash);
  transition: background 220ms ease, color 220ms ease;
}

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

button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  transform: translateY(0) scale(1);
  transition:
    transform 120ms ease,
    box-shadow 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    opacity 160ms ease;
  user-select: none;
}

button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  box-shadow: var(--shadow-button);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  box-shadow: 0 2px 6px rgba(23, 32, 27, 0.10);
  transform: translateY(1px) scale(0.985);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--accent-ring);
  outline-offset: 2px;
  border-color: var(--accent);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  box-shadow: none;
  transform: none;
}

.privacy-toggle {
  width: 100%;
  border-color: color-mix(in srgb, var(--accent) 35%, #58615d);
  background: #f5f7f6;
  font-weight: 800;
}

.privacy-toggle.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 94%, #fff), var(--accent));
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 24%, transparent);
}

.primary:hover:not(:disabled) {
  background: linear-gradient(180deg, var(--accent), var(--accent-dark));
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 28px;
  border-right: 1px solid var(--line);
  background: rgba(251, 252, 251, 0.88);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
}

h2 {
  font-size: 30px;
}

h3 {
  font-size: 17px;
}

.job-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.job-switch button {
  display: grid;
  grid-template-rows: 54px auto;
  gap: 8px;
  align-items: center;
  justify-items: center;
  min-height: 112px;
  padding: 8px;
}

.brand-mark {
  display: block;
  width: 100%;
  height: 54px;
  border-radius: 7px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.fay-tab .brand-mark {
  background-color: #0b5f93;
  background-image: url("/assets/fay-logo.svg?v=3");
}

.arqline-tab .brand-mark {
  background-color: #651e18;
  background-image: url("/assets/arqline-logo.svg?v=3");
}

.privacy-mode .brand-mark,
.privacy-mode-boot .brand-mark {
  background-image: none;
  background-color: #dfe5e2;
  position: relative;
}

.privacy-mode .brand-mark::after,
.privacy-mode-boot .brand-mark::after {
  content: "WORK";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #647069;
  font-size: 14px;
  font-weight: 900;
}

.job-switch button.active,
.nav-item.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent), 0 8px 18px color-mix(in srgb, var(--accent) 10%, transparent);
}

.nav-stack {
  display: grid;
  gap: 8px;
}

.nav-item {
  text-align: left;
  padding: 0 12px;
}

.guardrail {
  margin-top: auto;
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  box-shadow: 0 8px 20px rgba(23, 32, 27, 0.04);
}

.guardrail strong {
  color: var(--ink);
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 28px 32px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.90);
  backdrop-filter: blur(12px);
}

.status {
  max-width: 360px;
  padding: 8px 12px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 13px;
}

.ai-status {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.logout-button {
  display: block;
  min-height: 30px;
  margin: 8px 0 0 auto;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.view {
  display: none;
  padding: 28px 32px;
}

.view.active {
  display: block;
  animation: viewIn 180ms ease-out;
}

@keyframes viewIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.split,
.queue-layout,
.command-grid,
.audio-grid,
.calendar-grid,
.notepad-grid {
  display: grid;
  grid-template-columns: minmax(320px, 0.85fr) minmax(420px, 1.15fr);
  gap: 20px;
}

.command-grid,
.calendar-grid {
  grid-template-columns: minmax(300px, 0.7fr) minmax(420px, 1fr) minmax(300px, 0.7fr);
  align-items: start;
}

.panel {
  min-width: 0;
  padding: 20px;
  border: 1px solid color-mix(in srgb, var(--accent) 10%, var(--line));
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-soft);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

form {
  display: grid;
  gap: 16px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 11px;
  color: var(--ink);
  background: #fff;
  resize: vertical;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input:hover,
select:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

textarea,
pre {
  line-height: 1.45;
}

.small {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.empty {
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
}

.leak-bad {
  color: var(--warn);
  font-weight: 800;
}

.leak-ok {
  color: var(--ok);
  font-weight: 800;
}

.draft-list {
  display: grid;
  gap: 10px;
}

.draft-card,
.task-card,
.recurring-card,
.meeting-card,
.conflict-card {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  transition: box-shadow 160ms ease, border-color 160ms ease, background 160ms ease;
}

.draft-card:hover,
.recurring-card:hover,
.meeting-card:hover {
  border-color: color-mix(in srgb, var(--accent) 28%, var(--line));
  box-shadow: 0 10px 24px rgba(23, 32, 27, 0.07);
}

.task-card:hover,
.task-card:focus-within {
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  box-shadow: inset 4px 0 0 var(--accent), 0 8px 18px rgba(23, 32, 27, 0.06);
  background: color-mix(in srgb, var(--accent-soft) 28%, #fff);
}

.task-card.dragging {
  opacity: .72;
  box-shadow: inset 4px 0 0 var(--accent), 0 12px 28px rgba(23, 32, 27, 0.14);
}

.draft-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.draft-card strong,
.draft-card span,
.task-card strong,
.task-card span,
.recurring-card strong,
.recurring-card span,
.meeting-card strong,
.meeting-card span,
.conflict-card strong,
.conflict-card span {
  overflow-wrap: anywhere;
}

.privacy-mode .task-card strong,
.privacy-mode .task-card span,
.privacy-mode .recurring-card strong,
.privacy-mode .recurring-card span,
.privacy-mode .draft-card strong,
.privacy-mode .draft-card span {
  filter: blur(5px);
  transition: filter 120ms ease;
}

.privacy-mode .task-card:hover strong,
.privacy-mode .task-card:hover span,
.privacy-mode .task-card:focus-within strong,
.privacy-mode .task-card:focus-within span,
.privacy-mode .recurring-card:hover strong,
.privacy-mode .recurring-card:hover span,
.privacy-mode .recurring-card:focus-within strong,
.privacy-mode .recurring-card:focus-within span,
.privacy-mode .draft-card:hover strong,
.privacy-mode .draft-card:hover span,
.privacy-mode .draft-card:focus-within strong,
.privacy-mode .draft-card:focus-within span {
  filter: none;
}

.draft-card span,
.task-card span,
.recurring-card span {
  color: var(--muted);
  font-size: 12px;
}

.task-list,
.recurring-list,
.meeting-list,
.conflict-list {
  display: grid;
  gap: 10px;
}

.meeting-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-ring);
}

.conflict-card {
  border-color: #e3b5a7;
  background: #fff7f4;
}

.recurring-list {
  margin-top: 16px;
}

.task-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.audio-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

#audioPlayback {
  width: 100%;
  min-height: 42px;
}

.badge {
  display: inline-flex;
  width: max-content;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.badge.warn {
  background: #fbe7df;
  color: var(--warn);
}

#draftPreview {
  width: 100%;
  min-height: 520px;
  max-height: calc(100vh - 230px);
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f7faf8;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.privacy-mode #draftPreview:not(:focus) {
  color: transparent;
  text-shadow: 0 0 8px rgba(23, 32, 27, 0.65);
}

.privacy-mode input:not(:focus),
.privacy-mode textarea:not(:focus) {
  color: transparent;
  text-shadow: 0 0 7px rgba(23, 32, 27, 0.6);
}

.privacy-mode input::placeholder,
.privacy-mode textarea::placeholder {
  color: #9aa39f;
  text-shadow: none;
}

.editbar {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

.memory-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}

.wide {
  grid-column: 1 / -1;
}

.section-label {
  display: grid;
  gap: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.section-label p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background: var(--wash);
}

.auth-panel {
  width: min(440px, 100%);
  display: grid;
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.auth-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-message {
  min-height: 20px;
  color: var(--warn);
  font-size: 13px;
  font-weight: 800;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

@media (max-width: 900px) {
  .app-shell,
  .split,
  .queue-layout,
  .command-grid,
  .audio-grid,
  .calendar-grid,
  .notepad-grid,
  .memory-grid {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
