:root {
  --ink: #1d252c;
  --muted: #6a747c;
  --line: #e7e8e5;
  --paper: #f8f8f5;
  --red: #c8102e;
  --red-dark: #a20d26;
  --red-soft: #fbecef;
  --green: #19704c;
  --amber: #a86409;
  --shadow: 0 18px 50px rgba(31, 37, 42, .09);
  font-family: "DM Sans", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; background: var(--paper); }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin-top: 0; }
h1, h2, h3, .brand { font-family: "Manrope", sans-serif; }
.page-glow { position: fixed; z-index: -1; border-radius: 50%; opacity: .55; }
.page-glow-one { width: 28rem; height: 28rem; top: -15rem; right: -8rem; background: #f8d9de; }
.page-glow-two { width: 24rem; height: 24rem; bottom: -14rem; left: 20%; background: #e7eadf; }
.brand { display: flex; align-items: center; gap: .7rem; font-size: 1.15rem; font-weight: 800; letter-spacing: -.04em; }
.brand-mark { display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .55rem; color: #fff; background: var(--red); font-size: .95rem; }
.brand-centered { justify-content: center; }
.eyebrow { display: block; margin-bottom: .55rem; color: var(--red); font-size: .72rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.center-card { display: grid; place-content: center; gap: 2rem; min-height: 100vh; text-align: center; }
.spinner { width: 1.7rem; height: 1.7rem; margin: auto; border: 2px solid #ddd; border-top-color: var(--red); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-layout { display: grid; grid-template-columns: 1.1fr .9fr; min-height: 100vh; }
.auth-story { display: flex; flex-direction: column; justify-content: space-between; padding: 3rem 5vw; color: #fff; background: linear-gradient(150deg, #201f22 0%, #29272a 55%, #431622 100%); }
.auth-story .brand-mark { background: #fff; color: var(--red); }
.story-copy { max-width: 43rem; margin: 12vh 0; }
.story-copy .eyebrow { color: #f0a9b5; }
.story-copy h1 { margin-bottom: 1.5rem; font-size: clamp(3rem, 6vw, 6.5rem); line-height: .96; letter-spacing: -.075em; }
.story-copy h1 em { color: #ef8799; font-style: normal; }
.story-copy p { max-width: 33rem; color: #d8d2d4; font-size: 1.15rem; line-height: 1.7; }
.story-stats { display: flex; gap: 3rem; color: #ada5a8; font-size: .85rem; }
.story-stats strong { display: block; margin-bottom: .2rem; color: #fff; font-family: "Manrope"; font-size: 1.15rem; }
.auth-panel { display: grid; place-items: center; padding: 3rem max(3rem, 8vw); background: rgba(255,255,255,.72); backdrop-filter: blur(16px); }
.auth-panel > div { width: min(100%, 27rem); }
.auth-heading { margin-bottom: 2rem; }
.auth-heading h2, .sso-card h2 { margin-bottom: .5rem; font-size: 2rem; letter-spacing: -.045em; }
.auth-heading p, .sso-card p { color: var(--muted); }
.stack-form { display: grid; gap: 1rem; }
label { display: grid; gap: .45rem; color: #41494f; font-size: .82rem; font-weight: 600; }
input, textarea, select { width: 100%; border: 1px solid #d9dbd7; border-radius: .7rem; outline: none; color: var(--ink); background: #fff; transition: border .2s, box-shadow .2s; }
input, select { min-height: 2.9rem; padding: .7rem .85rem; }
textarea { padding: .85rem; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--red); box-shadow: 0 0 0 3px rgba(200,16,46,.1); }
.field-hint { margin: -.55rem 0 0; color: var(--muted); font-size: .75rem; }
.form-error { min-height: 1.1rem; margin: 0; color: var(--red); font-size: .82rem; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; min-height: 2.75rem; padding: .7rem 1rem; border: 0; border-radius: .65rem; cursor: pointer; font-weight: 700; text-decoration: none; transition: transform .18s, background .18s, box-shadow .18s; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: #fff; background: var(--red); box-shadow: 0 8px 22px rgba(200,16,46,.2); }
.button-primary:hover { background: var(--red-dark); }
.button-secondary { border: 1px solid var(--line); color: var(--ink); background: #fff; box-shadow: none; }
.button-wide { width: 100%; }
.text-button { display: block; margin: 1.5rem auto 0; border: 0; color: var(--red); background: transparent; cursor: pointer; font-weight: 600; }
.text-button-left { margin: .6rem 0 0 3rem; color: var(--muted); font-size: .8rem; }
.sso-card { text-align: center; }
.sso-card .button { margin-top: 1.2rem; }

.app-layout { display: grid; grid-template-columns: 16.5rem 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; display: flex; flex-direction: column; height: 100vh; padding: 2rem 1.2rem; border-right: 1px solid var(--line); background: rgba(255,255,255,.76); backdrop-filter: blur(14px); }
.sidebar .brand { padding: 0 .65rem; margin-bottom: 3rem; }
.sidebar nav { display: grid; gap: .35rem; }
.nav-item { display: grid; grid-template-columns: 1.5rem 1fr auto; align-items: center; width: 100%; padding: .78rem .75rem; border: 0; border-radius: .65rem; color: #5e676e; background: transparent; cursor: pointer; text-align: left; }
.nav-item > span:last-child { min-width: 1.65rem; padding: .15rem .45rem; border-radius: 1rem; background: #edeeeb; font-size: .72rem; text-align: center; }
.nav-item.active { color: var(--red); background: var(--red-soft); font-weight: 700; }
.nav-item.active > span:last-child { color: #fff; background: var(--red); }
.nav-icon { font-size: 1rem; }
.sidebar-bottom { margin-top: auto; padding: 1rem .65rem 0; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: .75rem; min-width: 0; }
.user-chip div { min-width: 0; }
.user-chip strong, .user-chip small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip strong { font-size: .85rem; }
.user-chip small { margin-top: .15rem; color: var(--muted); font-size: .7rem; }
.avatar { display: grid; flex: 0 0 auto; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 50%; color: #fff; background: #31373c; font-size: .8rem; font-weight: 700; }
.workspace { width: min(100%, 84rem); margin: 0 auto; padding: 4rem clamp(2rem, 5vw, 5rem); }
.workspace-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; margin-bottom: 2.5rem; }
.workspace-header h1 { margin-bottom: .4rem; font-size: clamp(2rem, 4vw, 3.25rem); letter-spacing: -.055em; }
.workspace-header p { margin-bottom: 0; color: var(--muted); }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 3.5rem; }
.summary-grid article { position: relative; min-height: 9rem; padding: 1.35rem; overflow: hidden; border: 1px solid var(--line); border-radius: .9rem; background: rgba(255,255,255,.72); }
.summary-grid article > span { color: var(--muted); font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.summary-grid strong { display: block; margin: .45rem 0 .2rem; font-family: "Manrope"; font-size: 2.4rem; letter-spacing: -.05em; }
.summary-grid small { color: var(--muted); }
.accent-card { color: #fff; border-color: #302c2d !important; background: linear-gradient(135deg, #2b292b, #4b1723) !important; }
.accent-card > span { color: #d2c9cb !important; }
.progress-track { position: absolute; right: 1.35rem; bottom: 1.55rem; left: 1.35rem; height: .3rem; overflow: hidden; border-radius: 1rem; background: rgba(255,255,255,.18); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: #ef8799; transition: width .4s; }
.section-heading { display: flex; justify-content: space-between; gap: 1.5rem; margin-bottom: 1.15rem; }
.section-heading h2 { margin-bottom: .25rem; font-size: 1.35rem; letter-spacing: -.035em; }
.section-heading p { margin-bottom: 0; color: var(--muted); font-size: .82rem; }
.list-actions { display: flex; align-items: center; gap: .55rem; }
.sort-control { display: flex; align-items: center; gap: .4rem; color: var(--muted); }
.sort-control select { width: auto; min-height: 2.55rem; padding-right: 2rem; }
.icon-button { width: 2.55rem; height: 2.55rem; border: 1px solid var(--line); border-radius: .6rem; color: var(--ink); background: #fff; cursor: pointer; font-size: 1.15rem; }
.export-button { min-height: 2.55rem; font-size: .82rem; }
.task-list { display: grid; gap: .65rem; }
.snapshot-list { display: grid; gap: .75rem; }
.snapshot-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem; padding: 1rem 1.1rem; border: 1px solid var(--line); border-radius: .8rem; background: rgba(255,255,255,.88); }
.snapshot-card h3 { margin-bottom: .25rem; font-size: .95rem; }
.snapshot-card p { margin: 0; color: var(--muted); font-size: .8rem; }
.snapshot-icon { display: grid; place-items: center; width: 2.75rem; height: 3.25rem; border-radius: .35rem; color: #fff; background: var(--red); font-size: .66rem; font-weight: 800; letter-spacing: .05em; box-shadow: inset 0 -.35rem rgba(0,0,0,.08); }
.archive-header { margin-bottom: 3.5rem; }
.task-card { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 1rem; padding: 1rem 1.05rem; border: 1px solid var(--line); border-radius: .75rem; background: rgba(255,255,255,.88); transition: border .2s, box-shadow .2s, transform .2s; }
.task-card:hover { border-color: #d1d3cf; box-shadow: 0 8px 25px rgba(31,37,42,.06); transform: translateY(-1px); }
.task-card.completed { opacity: .62; }
.task-card.completed h3 { text-decoration: line-through; }
.complete-button { display: grid; place-items: center; width: 1.5rem; height: 1.5rem; padding: 0; border: 1.5px solid #aeb4b4; border-radius: 50%; color: transparent; background: transparent; cursor: pointer; }
.completed .complete-button { border-color: var(--green); color: #fff; background: var(--green); }
.task-body { min-width: 0; }
.task-body h3 { overflow: hidden; margin-bottom: .2rem; font-family: "DM Sans"; font-size: .95rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.task-body p { overflow: hidden; margin-bottom: .5rem; color: var(--muted); font-size: .8rem; text-overflow: ellipsis; white-space: nowrap; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; color: var(--muted); font-size: .69rem; }
.priority { padding: .17rem .42rem; border-radius: 1rem; font-weight: 700; text-transform: capitalize; }
.priority-high { color: var(--red); background: var(--red-soft); }
.priority-medium { color: var(--amber); background: #fff3de; }
.priority-low { color: var(--green); background: #e9f5ef; }
.due.overdue { color: var(--red); font-weight: 700; }
.task-actions { display: flex; gap: .25rem; }
.task-actions button, .task-actions a { display: grid; place-items: center; width: 2rem; height: 2rem; border: 0; border-radius: .45rem; color: var(--muted); background: transparent; cursor: pointer; text-decoration: none; }
.task-actions button:hover, .task-actions a:hover { color: var(--ink); background: #f0f1ee; }
.task-actions .delete-task:hover { color: var(--red); background: var(--red-soft); }
.empty-state { padding: 4rem 2rem; border: 1px dashed #cfd2cd; border-radius: 1rem; text-align: center; background: rgba(255,255,255,.45); }
.empty-icon { display: grid; place-items: center; width: 3rem; height: 3rem; margin: 0 auto 1rem; border-radius: 50%; color: var(--green); background: #e9f5ef; font-size: 1.25rem; }
.empty-state h3 { margin-bottom: .4rem; }
.empty-state p { margin-bottom: 1.25rem; color: var(--muted); }
.task-dialog { width: min(92vw, 35rem); padding: 0; border: 0; border-radius: 1rem; box-shadow: var(--shadow); }
.task-dialog::backdrop { background: rgba(17,19,20,.52); backdrop-filter: blur(3px); }
.task-dialog form { display: grid; gap: 1rem; padding: 1.6rem; }
.dialog-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.dialog-heading h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.04em; }
.close-button { border: 0; color: var(--muted); background: transparent; cursor: pointer; font-size: 1.6rem; line-height: 1; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.dialog-actions { display: flex; justify-content: flex-end; gap: .6rem; padding-top: .4rem; }
.toast { position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 10; padding: .8rem 1rem; border-radius: .65rem; color: #fff; background: #262a2d; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateY(1rem); transition: .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

@media (max-width: 850px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-story { min-height: 38vh; padding: 2rem; }
  .story-copy { margin: 7vh 0 2rem; }
  .story-copy h1 { font-size: clamp(2.8rem, 13vw, 5rem); }
  .story-stats { display: none; }
  .auth-panel { padding: 3rem 1.5rem; }
  .app-layout { grid-template-columns: 1fr; padding-bottom: 4.5rem; }
  .sidebar { position: fixed; inset: auto 0 0; z-index: 5; display: block; width: 100%; height: auto; padding: .5rem; border-top: 1px solid var(--line); border-right: 0; }
  .sidebar .brand, .sidebar-bottom { display: none; }
  .sidebar nav { grid-template-columns: repeat(4, 1fr); }
  .nav-item { display: flex; flex-direction: column; gap: .15rem; justify-content: center; padding: .45rem; font-size: .68rem; }
  .nav-item > span:last-child { display: none; }
  .workspace { padding: 2rem 1rem; }
  .workspace-header { align-items: center; }
  .summary-grid { margin-bottom: 2.5rem; }
}

@media (max-width: 600px) {
  .workspace-header { align-items: flex-start; }
  .workspace-header .button { width: 2.8rem; padding: 0; font-size: 0; }
  .workspace-header .button span { font-size: 1.25rem; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .summary-grid article { min-height: 7.5rem; }
  .summary-grid .accent-card { grid-column: 1 / -1; min-height: 6.5rem; }
  .section-heading { display: block; }
  .list-actions { margin-top: 1rem; }
  .export-button { margin-left: auto; }
  .task-card { grid-template-columns: auto minmax(0, 1fr); }
  .snapshot-card { grid-template-columns: auto minmax(0, 1fr); }
  .snapshot-card .button { grid-column: 2; justify-self: start; }
  .task-actions { grid-column: 2; }
  .form-row { grid-template-columns: 1fr; }
}
