:root {
  color-scheme: light;
  --bg: #f5f4f1;
  --surface: #ffffff;
  --surface-soft: #faf9f7;
  --surface-hover: #f3f1ed;
  --line: #e9e6e1;
  --line-strong: #dcd7d0;
  --ink: #201d28;
  --ink-soft: #625e69;
  --muted: #716c78;
  --violet: #6e4ed8;
  --violet-dark: #5434bd;
  --violet-soft: #eee9fc;
  --violet-faint: #f7f4fe;
  --on-violet: #fff;
  --on-red: #fff;
  --red: #b73543;
  --red-soft: #fcebed;
  --green: #1c7554;
  --green-soft: #e7f6f0;
  --amber: #80500c;
  --amber-soft: #fff3d9;
  --shadow-sm: 0 1px 2px rgba(32, 29, 40, .04), 0 3px 12px rgba(32, 29, 40, .035);
  --shadow-md: 0 18px 45px rgba(32, 24, 47, .12), 0 2px 9px rgba(32, 24, 47, .08);
  --shadow-lg: 0 26px 70px rgba(26, 20, 38, .2), 0 6px 18px rgba(26, 20, 38, .1);
  --radius-sm: 10px;
  --radius: 15px;
  --radius-lg: 22px;
  --sidebar-width: 256px;
  --topbar-height: 72px;
  --ease: cubic-bezier(.2, .75, .25, 1);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121116;
  --surface: #1a181f;
  --surface-soft: #211f27;
  --surface-hover: #292630;
  --line: #302d37;
  --line-strong: #413c49;
  --ink: #f6f3fa;
  --ink-soft: #bbb5c4;
  --muted: #a19aa9;
  --violet: #ad8df1;
  --violet-dark: #b59cf5;
  --violet-soft: #33294b;
  --violet-faint: #25202f;
  --on-violet: #17131e;
  --on-red: #17131e;
  --red: #ee737d;
  --red-soft: #41252a;
  --green: #63c49e;
  --green-soft: #1f3b31;
  --amber: #e5ae56;
  --amber-soft: #41341f;
  --shadow-sm: 0 2px 12px rgba(0, 0, 0, .16);
  --shadow-md: 0 18px 45px rgba(0, 0, 0, .36);
  --shadow-lg: 0 26px 70px rgba(0, 0, 0, .52);
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body.has-overlay { overflow: hidden; }
button, input, textarea, select { font: inherit; }
button, select { cursor: pointer; }
button { color: inherit; }
a { color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--violet);
  outline-offset: 2px;
}

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

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 12px;
  left: 12px;
  transform: translateY(-150%);
  padding: 10px 15px;
  border-radius: 9px;
  background: var(--ink);
  color: var(--surface);
  text-decoration: none;
  transition: transform .2s;
}
.skip-link:focus { transform: translateY(0); }

.brand, .story-brand, .auth-mobile-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 760;
  letter-spacing: -.04em;
}

.brand-mark {
  display: grid;
  width: 31px;
  height: 31px;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: #251a3e;
}
.brand-mark img { width: 31px; height: 31px; }

.eyebrow {
  margin: 0 0 7px;
  color: var(--violet);
  font-size: 11px;
  font-weight: 780;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 17px;
  border: 1px solid transparent;
  border-radius: 11px;
  font-weight: 680;
  line-height: 1.1;
  text-decoration: none;
  transition: transform .16s var(--ease), background .16s, border-color .16s, box-shadow .16s, opacity .16s;
}
.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button:disabled { cursor: wait; opacity: .62; transform: none; }
.button-primary { background: var(--violet); color: var(--on-violet); box-shadow: 0 5px 13px rgba(110, 78, 216, .2); }
.button-primary:hover { background: var(--violet-dark); box-shadow: 0 7px 18px rgba(110, 78, 216, .26); }
.button-secondary { border-color: var(--line); background: var(--surface); color: var(--ink-soft); box-shadow: var(--shadow-sm); }
.button-secondary:hover { border-color: var(--line-strong); background: var(--surface-hover); color: var(--ink); }
.button-large { min-height: 50px; width: 100%; justify-content: space-between; padding-inline: 20px; }

.icon-button {
  display: inline-grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  transition: background .16s, color .16s, border-color .16s, transform .16s;
}
.icon-button:hover { background: var(--surface-hover); color: var(--ink); }
.icon-button:active { transform: scale(.96); }
.icon-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button > span { font-size: 25px; font-weight: 300; line-height: 1; transform: translateY(-1px); }
.text-button { padding: 5px; border: 0; background: transparent; color: var(--violet); font-size: 13px; font-weight: 680; }
.text-button:hover { text-decoration: underline; }

/* Authentication */
.auth-shell {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-columns: minmax(420px, .98fr) minmax(430px, 1.02fr);
  background: var(--surface);
}

.auth-story {
  position: relative;
  display: flex;
  min-height: 620px;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: clamp(30px, 5vw, 72px);
  background:
    radial-gradient(circle at 80% 20%, rgba(139, 103, 239, .28), transparent 28%),
    radial-gradient(circle at 8% 90%, rgba(104, 67, 183, .23), transparent 28%),
    linear-gradient(148deg, #191127 0%, #27183c 48%, #412568 100%);
  color: #fff;
}
.auth-story::before {
  content: "";
  position: absolute;
  width: 460px;
  height: 460px;
  right: -210px;
  bottom: -140px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 50%;
  box-shadow: 0 0 0 74px rgba(255,255,255,.025), 0 0 0 148px rgba(255,255,255,.02);
}
.auth-story > * { position: relative; z-index: 1; }
.story-brand .brand-mark { box-shadow: inset 0 0 0 1px rgba(255,255,255,.15); }
.story-copy { max-width: 520px; margin-block: 70px; }
.story-copy .eyebrow { color: #bdaaf2; }
.story-copy h2 { margin: 0 0 24px; font-size: clamp(43px, 5vw, 72px); line-height: .98; letter-spacing: -.065em; }
.story-copy > p:last-child { max-width: 440px; margin: 0; color: rgba(255,255,255,.67); font-size: 17px; line-height: 1.65; }
.story-card {
  max-width: 450px;
  padding: 20px 22px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  background: rgba(255,255,255,.09);
  box-shadow: 0 20px 60px rgba(0,0,0,.14);
  backdrop-filter: blur(16px);
}
.story-card-top { display: flex; align-items: center; gap: 9px; color: rgba(255,255,255,.72); font-size: 13px; }
.story-check { display: grid; width: 23px; height: 23px; place-items: center; border-radius: 50%; background: rgba(112, 231, 185, .16); color: #8be4c2; }
.story-time { margin-left: auto; color: rgba(255,255,255,.4); }
.story-card > p { margin: 16px 0 17px; font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
.story-people { display: flex; align-items: center; }
.story-people > span { display: grid; width: 28px; height: 28px; place-items: center; margin-right: -6px; border: 2px solid #302047; border-radius: 50%; background: #8463db; font-size: 10px; font-weight: 700; }
.story-people > span:nth-child(2) { background: #3d8d79; }
.story-people small { margin-left: 13px; color: rgba(255,255,255,.5); }

.auth-panel { display: grid; min-width: 0; place-items: center; padding: 45px clamp(30px, 7vw, 110px); background: var(--surface); }
.auth-box { width: min(100%, 410px); }
.auth-mobile-brand { display: none; margin-bottom: 60px; }
.auth-form { display: grid; gap: 20px; }
.auth-heading { margin-bottom: 13px; }
.auth-heading h1 { margin: 0 0 9px; font-size: clamp(33px, 4vw, 43px); line-height: 1.08; letter-spacing: -.045em; }
.auth-heading > p:last-child { margin: 0; color: var(--ink-soft); }
.auth-note { margin: 5px 0 0; color: var(--muted); font-size: 12px; line-height: 1.55; text-align: center; }
.invite-badge { display: grid; width: 46px; height: 46px; place-items: center; margin-bottom: 2px; border-radius: 14px; background: var(--violet-soft); color: var(--violet); font-size: 21px; }

.field { display: grid; min-width: 0; gap: 8px; color: var(--ink); }
.field > span:first-child, .field > legend { font-size: 13px; font-weight: 650; }
.field small { color: var(--muted); font-size: 11px; font-weight: 450; }
.field input, .field textarea, .field select, .compact-select select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 11px;
  outline: 0;
  background: var(--surface);
  color: var(--ink);
  transition: border-color .16s, box-shadow .16s, background .16s;
}
.field input, .field select { height: 45px; padding: 0 13px; }
.field textarea { min-height: 112px; padding: 12px 13px; line-height: 1.55; resize: vertical; }
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .78; }
.field input:focus, .field textarea:focus, .field select:focus, .compact-select select:focus {
  outline: 2px solid var(--violet);
  outline-offset: 1px;
  border-color: color-mix(in srgb, var(--violet) 68%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 11%, transparent);
}
.password-field, .input-with-icon { position: relative; display: block; }
.password-field input { padding-right: 47px; }
.password-field .icon-button { position: absolute; top: 4px; right: 4px; width: 37px; height: 37px; }
.input-with-icon svg { position: absolute; z-index: 1; top: 13px; left: 12px; width: 19px; height: 19px; fill: none; stroke: var(--muted); stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.input-with-icon input { padding-left: 39px; }
.form-error { min-height: 0; margin: -7px 0 0; color: var(--red); font-size: 13px; }
.form-error:empty { display: none; }

/* Application shell */
.app-shell { min-height: 100vh; min-height: 100dvh; }
.sidebar {
  position: fixed;
  z-index: 20;
  inset: 0 auto 0 0;
  display: flex;
  width: var(--sidebar-width);
  flex-direction: column;
  padding: 27px 18px 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.sidebar-brand { padding-inline: 7px; }
.new-fix-button { width: 100%; margin: 31px 0 25px; justify-content: flex-start; padding-inline: 13px; }
.new-fix-button .button-plus { font-size: 21px; font-weight: 400; line-height: 1; }
.new-fix-button kbd { margin-left: auto; padding: 2px 6px; border: 1px solid rgba(255,255,255,.22); border-radius: 5px; background: rgba(255,255,255,.11); color: rgba(255,255,255,.78); font-size: 10px; font-family: inherit; font-weight: 500; }
.side-nav { display: grid; gap: 3px; }
.nav-label { margin: 0 12px 7px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.nav-item {
  display: flex;
  width: 100%;
  min-height: 43px;
  align-items: center;
  gap: 11px;
  padding: 8px 11px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  transition: background .16s, color .16s;
}
.nav-item:hover { background: var(--surface-hover); color: var(--ink); }
.nav-item.is-active { background: var(--violet-soft); color: var(--violet-dark); font-weight: 650; }
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.nav-count { min-width: 23px; margin-left: auto; padding: 1px 6px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 5%, transparent); color: var(--muted); font-size: 11px; text-align: center; }
.nav-item.is-active .nav-count { background: color-mix(in srgb, var(--violet) 12%, transparent); color: var(--violet-dark); }
.sidebar-bottom { display: grid; gap: 13px; margin-top: auto; }
.team-dot { width: 7px; height: 7px; margin-left: auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.profile-card { display: flex; min-width: 0; align-items: center; gap: 10px; padding: 13px 9px 7px; border-top: 1px solid var(--line); }
.avatar {
  display: inline-grid;
  width: 35px;
  height: 35px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 11px;
  background: var(--violet-soft);
  color: var(--violet-dark);
  font-size: 12px;
  font-weight: 760;
}
.profile-copy { display: grid; min-width: 0; flex: 1; line-height: 1.3; }
.profile-copy strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy small { color: var(--muted); font-size: 10px; }
.profile-card .icon-button { width: 34px; height: 34px; }

.workspace { min-height: 100vh; margin-left: var(--sidebar-width); }
.topbar {
  position: sticky;
  z-index: 15;
  top: 0;
  display: flex;
  height: var(--topbar-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(24px, 4vw, 52px);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(14px);
}
.mobile-brand { display: none; }
.search-box { position: relative; display: block; width: min(430px, 46vw); }
.search-box svg { position: absolute; top: 11px; left: 13px; width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search-box input { width: 100%; height: 40px; padding: 0 42px 0 40px; border: 1px solid var(--line); border-radius: 10px; outline: none; background: var(--surface-soft); color: var(--ink); font-size: 13px; transition: background .16s, border-color .16s, box-shadow .16s; }
.search-box input:focus { outline: 2px solid var(--violet); outline-offset: 1px; border-color: color-mix(in srgb, var(--violet) 45%, var(--line)); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 8%, transparent); }
.search-box input::placeholder { color: var(--muted); }
.search-box kbd { position: absolute; top: 10px; right: 10px; padding: 2px 7px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--muted); font-family: inherit; font-size: 11px; }
.topbar-actions { display: flex; align-items: center; gap: 7px; }
.theme-button { border-color: var(--line); background: var(--surface); }
.moon-icon { display: none; }
[data-theme="dark"] .sun-icon { display: none; }
[data-theme="dark"] .moon-icon { display: block; }
.top-profile { display: flex; align-items: center; gap: 9px; padding: 3px 6px 3px 4px; border: 0; border-radius: 11px; background: transparent; font-size: 12px; font-weight: 650; }
.top-profile:hover { background: var(--surface-hover); }
.top-profile .avatar { width: 34px; height: 34px; }
.top-profile svg { width: 16px; height: 16px; fill: none; stroke: var(--muted); stroke-width: 1.8; }

.content { width: min(100%, 1240px); margin: 0 auto; padding: 43px clamp(24px, 4vw, 52px) 80px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
.page-heading h1 { margin: 0 0 7px; font-size: clamp(30px, 3vw, 39px); line-height: 1.05; letter-spacing: -.045em; }
.page-heading > div > p:last-child { margin: 0; color: var(--ink-soft); font-size: 14px; }
.mobile-create-button { display: none; }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; margin: 29px 0 35px; }
.summary-card { position: relative; display: flex; min-height: 97px; align-items: center; gap: 13px; overflow: hidden; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.summary-icon { display: grid; width: 37px; height: 37px; flex: 0 0 auto; place-items: center; border-radius: 11px; background: var(--violet-soft); color: var(--violet-dark); font-size: 18px; font-weight: 700; }
.summary-card div { display: grid; line-height: 1.2; }
.summary-card strong { font-size: 24px; letter-spacing: -.03em; }
.summary-card div span { margin-top: 3px; color: var(--ink-soft); font-size: 11px; }
.summary-card > small { margin-left: auto; align-self: flex-end; color: var(--muted); font-size: 10px; }
.summary-urgent .summary-icon { background: var(--red-soft); color: var(--red); }
.summary-done .summary-icon { background: var(--green-soft); color: var(--green); }

.list-toolbar { display: flex; min-height: 43px; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.list-toolbar > p { margin: 0; font-size: 13px; font-weight: 680; }
.toolbar-actions { display: flex; align-items: center; gap: 6px; }
.compact-select select { height: 35px; padding: 0 30px 0 10px; border-color: transparent; background: transparent; color: var(--ink-soft); font-size: 11px; }
.refresh-button { width: 35px; height: 35px; }
.refresh-button.is-spinning svg { animation: spin .65s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.task-list { display: grid; gap: 9px; }
.task-card {
  position: relative;
  display: grid;
  grid-template-columns: 5px minmax(0, 1fr) auto;
  gap: 17px;
  overflow: hidden;
  padding: 17px 18px 17px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: border-color .17s, box-shadow .17s, transform .17s var(--ease), background .17s;
}
.task-card:hover { z-index: 1; transform: translateY(-1px); border-color: color-mix(in srgb, var(--violet) 22%, var(--line)); box-shadow: 0 8px 25px rgba(32,29,40,.07); }
.task-card.is-done { opacity: .75; }
.task-card.is-done:hover { opacity: 1; }
.task-card-accent { width: 3px; height: calc(100% - 14px); align-self: center; border-radius: 0 4px 4px 0; background: var(--line-strong); }
.task-card.is-urgent .task-card-accent { background: var(--red); }
.task-card.is-done .task-card-accent { background: var(--green); }
.task-card-main { min-width: 0; padding-left: 1px; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; margin-bottom: 7px; color: var(--muted); font-size: 10px; }
.task-number { color: var(--violet); font-size: 10px; font-weight: 760; letter-spacing: .07em; text-transform: uppercase; }
.dot-separator::before { content: "·"; margin-right: 7px; }
.priority-badge, .status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 7px; border-radius: 6px; font-size: 9px; font-weight: 760; letter-spacing: .05em; text-transform: uppercase; }
.priority-badge { background: var(--red-soft); color: var(--red); }
.status-badge { background: var(--green-soft); color: var(--green); }
.status-badge.status-progress { background: var(--amber-soft); color: var(--amber); }
.task-card h2 { margin: 0; font-size: 15px; font-weight: 680; line-height: 1.4; letter-spacing: -.012em; }
.task-card h2 button { display: inline; padding: 0; border: 0; background: transparent; color: inherit; text-align: left; }
.task-card h2 button::after { content: ""; position: absolute; inset: 0; }
.task-description { display: -webkit-box; max-width: 740px; overflow: hidden; margin: 5px 0 0; color: var(--ink-soft); font-size: 12px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 1; }
.task-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 13px; margin-top: 13px; color: var(--muted); font-size: 10px; }
.task-foot-item { display: inline-flex; min-width: 0; align-items: center; gap: 5px; }
.task-foot-item svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.task-url { position: relative; z-index: 2; max-width: 260px; overflow: hidden; color: var(--violet); text-decoration: none; text-overflow: ellipsis; white-space: nowrap; }
.task-url:hover { text-decoration: underline; }
.task-card-side { display: flex; min-width: 100px; align-items: center; justify-content: flex-end; gap: 10px; padding-left: 9px; }
.avatar-stack { display: flex; justify-content: flex-end; }
.avatar-stack .avatar { width: 29px; height: 29px; margin-left: -7px; border: 2px solid var(--surface); border-radius: 9px; font-size: 9px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.card-chevron { color: var(--muted); font-size: 20px; font-weight: 300; }

.empty-state { display: grid; min-height: 315px; place-items: center; padding: 50px 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius-lg); background: color-mix(in srgb, var(--surface) 62%, transparent); text-align: center; }
.empty-state-inner { max-width: 350px; }
.empty-icon { display: grid; width: 55px; height: 55px; place-items: center; margin: 0 auto 17px; border-radius: 17px; background: var(--violet-soft); color: var(--violet); font-size: 23px; }
.empty-state h2 { margin: 0 0 7px; font-size: 18px; }
.empty-state p { margin: 0 0 21px; color: var(--ink-soft); font-size: 13px; }
.skeleton-card { height: 112px; border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(90deg, var(--surface) 10%, var(--surface-hover) 50%, var(--surface) 90%); background-size: 200% 100%; animation: shimmer 1.35s infinite linear; }
@keyframes shimmer { to { background-position: -200% 0; } }
.mobile-nav { display: none; }

/* Modals */
.modal {
  width: min(calc(100% - 32px), 680px);
  max-height: min(880px, calc(100dvh - 40px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
}
.modal::backdrop, .image-modal::backdrop { background: rgba(15, 11, 23, .52); backdrop-filter: blur(4px); }
.modal[open] { animation: modal-in .22s var(--ease); }
@keyframes modal-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
.modal > form { display: flex; max-height: inherit; flex-direction: column; }
.modal-header { display: flex; flex: 0 0 auto; align-items: flex-start; justify-content: space-between; padding: 24px 26px 18px; border-bottom: 1px solid var(--line); }
.modal-header h2 { margin: 0; font-size: 24px; line-height: 1.1; letter-spacing: -.035em; }
.modal-header .eyebrow { margin-bottom: 6px; }
.modal-body { min-height: 0; padding: 22px 26px; overflow-y: auto; }
.create-modal .modal-body, .edit-modal .modal-body { display: grid; gap: 19px; }
.modal-footer { display: flex; flex: 0 0 auto; justify-content: flex-end; gap: 9px; padding: 16px 26px calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface-soft); }
.field-title input { height: 50px; font-size: 17px; font-weight: 600; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(130px, .7fr); gap: 13px; }
.assignee-field { margin: 0; padding: 0; border: 0; }
.assignee-field legend { margin-bottom: 9px; }
.assignee-options { display: flex; min-height: 38px; flex-wrap: wrap; gap: 7px; }
.assignee-chip { position: relative; display: inline-flex; }
.assignee-chip input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.assignee-chip span { display: inline-flex; align-items: center; gap: 7px; padding: 5px 10px 5px 6px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink-soft); font-size: 11px; font-weight: 600; cursor: pointer; transition: border-color .16s, color .16s, background .16s; }
.assignee-chip span::before { content: attr(data-initials); display: grid; width: 24px; height: 24px; place-items: center; border-radius: 7px; background: var(--surface-hover); color: var(--ink-soft); font-size: 8px; }
.assignee-chip input:checked + span { border-color: color-mix(in srgb, var(--violet) 42%, var(--line)); background: var(--violet-soft); color: var(--violet-dark); }
.assignee-chip input:checked + span::before { background: var(--violet); color: var(--on-violet); }
.assignee-chip input:focus-visible + span { outline: 3px solid var(--violet); outline-offset: 2px; }
.muted { color: var(--muted); font-size: 12px; }

.drop-zone { display: grid; min-height: 119px; place-items: center; padding: 17px; border: 1.5px dashed var(--line-strong); border-radius: 13px; background: var(--surface-soft); color: var(--ink-soft); text-align: center; transition: border-color .16s, background .16s, transform .16s; }
.drop-zone:hover, .drop-zone.is-dragging { border-color: var(--violet); background: var(--violet-faint); }
.drop-zone.is-dragging { transform: scale(.995); }
.drop-zone p { margin: 6px 0 2px; font-size: 12px; }
.drop-zone p button { padding: 0; border: 0; background: none; color: var(--violet); font-weight: 650; text-decoration: underline; text-underline-offset: 2px; }
.drop-zone small { color: var(--muted); font-size: 10px; }
.drop-icon { color: var(--violet); }
.drop-icon svg { width: 25px; height: 25px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.attachment-preview { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-item { position: relative; width: 74px; height: 62px; overflow: hidden; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-hover); }
.preview-item img { width: 100%; height: 100%; object-fit: cover; }
.preview-item video { width: 100%; height: 100%; object-fit: cover; }
.video-mark { position: absolute; inset: 50% auto auto 50%; display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; background: rgba(20,17,25,.72); color: #fff; font-size: 8px; transform: translate(-50%, -50%); }
.preview-item button { position: absolute; top: 3px; right: 3px; display: grid; width: 20px; height: 20px; place-items: center; padding: 0; border: 0; border-radius: 6px; background: rgba(20,17,25,.72); color: #fff; font-size: 14px; line-height: 1; }
.preview-item small { position: absolute; inset: auto 3px 3px; overflow: hidden; padding: 2px 4px; border-radius: 4px; background: rgba(20,17,25,.66); color: #fff; font-size: 7px; text-overflow: ellipsis; white-space: nowrap; }

.voice-box { display: flex; min-height: 64px; align-items: center; gap: 11px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.voice-button { display: grid; width: 40px; height: 40px; flex: 0 0 auto; place-items: center; padding: 0; border: 0; border-radius: 12px; background: var(--violet-soft); color: var(--violet); }
.voice-button:hover { background: var(--violet); color: var(--on-violet); }
.voice-button svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.voice-box.is-recording { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); background: var(--red-soft); }
.voice-box.is-recording .voice-button { background: var(--red); color: var(--on-red); animation: pulse 1.5s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--red) 12%, transparent); } }
.voice-box.has-audio .voice-button { background: var(--green-soft); color: var(--green); }
.voice-copy { display: grid; min-width: 0; flex: 1; line-height: 1.35; }
.voice-copy strong { font-size: 12px; }
.voice-copy small { overflow: hidden; color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.voice-box.has-error .voice-copy small { color: var(--amber); line-height: 1.35; white-space: normal; }
.voice-preview { width: 100%; height: 40px; }
.record-time { color: var(--red); font-variant-numeric: tabular-nums; font-size: 11px; font-weight: 700; }

/* Team */
.team-modal { width: min(calc(100% - 32px), 610px); }
.team-modal[open] { display: flex; flex-direction: column; }
.team-modal .modal-body { flex: 1 1 auto; min-height: 0; padding-bottom: 27px; }
.team-list { display: grid; }
.team-row { display: flex; align-items: center; gap: 12px; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.team-row:last-child { border-bottom: 0; }
.team-row .avatar { width: 39px; height: 39px; }
.team-person { display: grid; min-width: 0; flex: 1; line-height: 1.4; }
.team-person strong { font-size: 13px; }
.team-person small { color: var(--muted); font-size: 10px; }
.role-badge { padding: 4px 8px; border-radius: 7px; background: var(--surface-hover); color: var(--ink-soft); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.role-badge.is-admin { background: var(--violet-soft); color: var(--violet); }
.role-badge.is-invited { background: var(--amber-soft); color: var(--amber); }
.invite-section { display: grid; gap: 16px; margin-top: 23px; padding: 19px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-soft); }
.invite-section h3 { margin: 0 0 3px; font-size: 15px; }
.invite-section p { margin: 0; color: var(--ink-soft); font-size: 11px; }
.invite-section form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 8px; }
.invite-section .button { min-height: 45px; }
.copy-field { display: flex; gap: 7px; }
.copy-field input { flex: 1; }
.agent-access-section { display: grid; gap: 15px; margin-top: 24px; padding-top: 23px; border-top: 1px solid var(--line); }
.section-copy h3 { margin: 0 0 4px; font-size: 15px; }
.section-copy p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.55; }
.api-key-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.api-key-form .button { min-height: 45px; }
.api-key-secret { display: grid; gap: 9px; padding: 14px; border: 1px solid color-mix(in srgb, var(--amber) 35%, var(--line)); border-radius: 12px; background: var(--amber-soft); }
.api-key-secret > strong { color: var(--amber); font-size: 11px; }
.api-key-secret input { min-width: 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 10px; }
.api-key-secret .text-button { justify-self: start; color: var(--violet); }
.api-key-list { display: grid; gap: 7px; }
.api-key-row { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); }
.api-key-meta { display: grid; min-width: 0; flex: 1; line-height: 1.4; }
.api-key-meta strong { overflow: hidden; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.api-key-meta small { color: var(--muted); font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 8px; }
.api-key-row .text-button { color: var(--red); }
.api-key-row.is-revoked { opacity: .58; }

/* Drawer */
.drawer-layer { position: fixed; z-index: 100; inset: 0; }
.drawer-backdrop { position: absolute; inset: 0; width: 100%; border: 0; background: rgba(21, 16, 30, .34); backdrop-filter: blur(2px); animation: fade-in .18s; }
@keyframes fade-in { from { opacity: 0; } }
.task-drawer { position: absolute; inset: 0 0 0 auto; display: flex; width: min(620px, 100%); flex-direction: column; background: var(--surface); box-shadow: -18px 0 50px rgba(24,18,34,.15); animation: drawer-in .27s var(--ease); }
@keyframes drawer-in { from { transform: translateX(100%); } }
.drawer-header { display: flex; height: 67px; flex: 0 0 auto; align-items: center; justify-content: space-between; padding: 0 25px; border-bottom: 1px solid var(--line); }
.drawer-actions { display: flex; gap: 3px; }
.drawer-scroll { min-height: 0; padding: 27px 31px 45px; overflow-y: auto; }
.drawer-title-row { display: flex; align-items: flex-start; gap: 12px; }
.drawer-title-row h2 { flex: 1; margin: 0; font-size: clamp(23px, 3vw, 30px); line-height: 1.2; letter-spacing: -.035em; }
.drawer-description { margin: 17px 0 0; color: var(--ink-soft); font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.drawer-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 27px 0; overflow: hidden; border: 1px solid var(--line); border-radius: 13px; background: var(--line); }
.detail-cell { min-height: 73px; padding: 14px 15px; background: var(--surface-soft); }
.detail-cell > span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 680; letter-spacing: .07em; text-transform: uppercase; }
.detail-cell strong, .detail-cell a { display: block; overflow: hidden; color: var(--ink); font-size: 12px; font-weight: 620; text-overflow: ellipsis; white-space: nowrap; }
.detail-cell a { color: var(--violet); text-decoration: none; }
.detail-cell a:hover { text-decoration: underline; }
.drawer-section { margin-top: 28px; }
.drawer-section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 11px; }
.drawer-section h3 { margin: 0; font-size: 13px; }
.drawer-section-title small { color: var(--muted); font-size: 10px; }
.screenshot-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.screenshot-button { position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; padding: 0; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-hover); }
.screenshot-button img { width: 100%; height: 100%; object-fit: cover; transition: transform .3s var(--ease); }
.screenshot-button:hover img { transform: scale(1.03); }
.screenshot-button span { position: absolute; right: 7px; bottom: 7px; padding: 4px 7px; border-radius: 6px; background: rgba(17,15,21,.72); color: #fff; font-size: 8px; }
.video-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.video-card { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; background: #111; }
.video-card video { display: block; width: 100%; max-height: 390px; background: #111; }
.video-card small { display: block; overflow: hidden; padding: 8px 10px; background: var(--surface-soft); color: var(--muted); font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.audio-player { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-soft); }
.audio-player audio { width: 100%; height: 36px; }

.comments { display: grid; gap: 13px; }
.comment { display: grid; grid-template-columns: 32px 1fr; gap: 10px; }
.comment .avatar { width: 32px; height: 32px; border-radius: 9px; font-size: 9px; }
.comment-body { min-width: 0; padding: 10px 12px; border-radius: 4px 12px 12px; background: var(--surface-soft); }
.comment-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.comment-head strong { font-size: 10px; }
.comment-head time { color: var(--muted); font-size: 9px; }
.comment-body p { margin: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.no-comments { padding: 17px; border: 1px dashed var(--line); border-radius: 11px; color: var(--muted); font-size: 11px; text-align: center; }
.comment-form { display: grid; gap: 8px; margin-top: 14px; }
.comment-form textarea { width: 100%; min-height: 76px; padding: 11px 12px; border: 1px solid var(--line); border-radius: 11px; outline: 0; background: var(--surface); color: var(--ink); line-height: 1.5; resize: vertical; }
.comment-form textarea:focus { outline: 2px solid var(--violet); outline-offset: 1px; border-color: var(--violet); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 9%, transparent); }
.comment-form .button { justify-self: end; min-height: 38px; padding: 8px 14px; font-size: 11px; }
.status-action { display: flex; flex-wrap: wrap; align-items: center; gap: 9px; margin-top: 24px; padding: 15px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); }
.status-action-copy { display: grid; min-width: 190px; flex: 1; }
.status-action-copy strong { font-size: 12px; }
.status-action-copy small { color: var(--muted); font-size: 10px; }
.status-action .button { min-height: 39px; font-size: 11px; }
.status-action.is-done { background: var(--green-soft); }

.image-modal { width: auto; max-width: min(94vw, 1500px); max-height: 92vh; padding: 0; overflow: visible; border: 0; background: transparent; box-shadow: none; }
.image-modal img { max-width: 94vw; max-height: 90vh; border-radius: 10px; box-shadow: var(--shadow-lg); object-fit: contain; }
.image-close { position: fixed; top: 18px; right: 18px; display: grid; width: 42px; height: 42px; place-items: center; padding: 0; border: 1px solid rgba(255,255,255,.2); border-radius: 50%; background: rgba(20,16,26,.72); color: #fff; font-size: 26px; }

.toast-stack { position: fixed; z-index: 300; right: 20px; bottom: 20px; display: grid; width: min(360px, calc(100% - 40px)); gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--ink); color: var(--surface); box-shadow: var(--shadow-md); font-size: 12px; animation: toast-in .25s var(--ease); }
.toast::before { content: "✓"; display: grid; width: 20px; height: 20px; place-items: center; border-radius: 50%; background: rgba(255,255,255,.15); }
.toast.is-error::before { content: "!"; background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1000px) {
  :root { --sidebar-width: 218px; }
  .sidebar { padding-inline: 12px; }
  .summary-card > small { display: none; }
  .task-card-side { min-width: 65px; }
  .auth-story { padding: 42px; }
}

@media (max-width: 880px) {
  .auth-shell { display: block; background: var(--surface); }
  .auth-story { display: none; }
  .auth-panel { min-height: 100vh; min-height: 100dvh; padding: max(28px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom)); }
  .auth-mobile-brand { display: flex; }
  .auth-box { width: min(100%, 430px); }
}

@media (max-width: 760px) {
  :root { --topbar-height: 62px; }
  .auth-shell { display: block; background: var(--surface); }
  .auth-story { display: none; }
  .auth-panel { min-height: 100vh; min-height: 100dvh; padding: max(28px, env(safe-area-inset-top)) 24px max(32px, env(safe-area-inset-bottom)); }
  .auth-mobile-brand { display: flex; }
  .auth-box { width: min(100%, 430px); }
  .sidebar { display: none; }
  .workspace { margin-left: 0; padding-bottom: calc(74px + env(safe-area-inset-bottom)); }
  .topbar { padding: 0 16px; }
  .mobile-brand { display: flex; font-size: 16px; }
  .mobile-brand .brand-mark { width: 29px; height: 29px; }
  .search-box { display: none; }
  .top-profile > span:not(.avatar), .top-profile > svg { display: none; }
  .content { padding: 27px 16px 40px; }
  .page-heading { align-items: center; }
  .page-heading .eyebrow { display: none; }
  .page-heading h1 { margin-bottom: 4px; font-size: 29px; }
  .page-heading > div > p:last-child { max-width: 250px; font-size: 11px; }
  .mobile-create-button { display: inline-flex; min-height: 40px; padding-inline: 13px; font-size: 12px; }
  .summary-grid { gap: 7px; margin: 22px 0 27px; }
  .summary-card { min-height: 81px; gap: 8px; padding: 12px 10px; }
  .summary-icon { width: 29px; height: 29px; border-radius: 9px; font-size: 14px; }
  .summary-card strong { font-size: 20px; }
  .summary-card div span { font-size: 9px; }
  .task-card { grid-template-columns: 4px minmax(0, 1fr); gap: 12px; padding: 15px 15px 15px 0; }
  .task-card-side { display: none; }
  .task-card h2 { font-size: 14px; }
  .task-description { -webkit-line-clamp: 2; }
  .task-foot { gap: 10px; }
  .task-url { max-width: 170px; }
  .mobile-nav { position: fixed; z-index: 40; inset: auto 0 0; display: grid; height: calc(65px + env(safe-area-inset-bottom)); grid-template-columns: repeat(5, 1fr); align-items: start; padding: 7px 5px env(safe-area-inset-bottom); border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(14px); }
  .mobile-nav button { display: grid; min-width: 0; place-items: center; gap: 1px; padding: 4px 2px; border: 0; background: transparent; color: var(--muted); }
  .mobile-nav button > span { font-size: 18px; line-height: 1.2; }
  .mobile-nav button > small { font-size: 8px; }
  .mobile-nav button.is-active { color: var(--violet); }
  .mobile-nav .mobile-nav-create { position: relative; top: -21px; display: grid; width: 48px; height: 48px; justify-self: center; place-items: center; border: 4px solid var(--bg); border-radius: 15px; background: var(--violet); color: var(--on-violet); box-shadow: 0 7px 18px rgba(110,78,216,.3); }
  .mobile-nav .mobile-nav-create > span { font-size: 27px; font-weight: 300; }
  .modal { width: 100%; max-width: none; max-height: calc(100dvh - 18px); margin: auto 0 0; border-width: 1px 0 0; border-radius: 21px 21px 0 0; }
  .modal[open] { animation-name: sheet-in; }
  @keyframes sheet-in { from { opacity: 0; transform: translateY(100%); } }
  .modal-header { padding: 20px 18px 16px; }
  .modal-header h2 { font-size: 21px; }
  .modal-body { padding: 19px 18px; }
  .modal-footer { padding-inline: 18px; }
  .form-grid { grid-template-columns: 1fr; }
  .drop-zone { min-height: 108px; }
  .invite-section form { grid-template-columns: 1fr; }
  .invite-section .button { width: 100%; }
  .api-key-form { grid-template-columns: 1fr; }
  .api-key-form .button { width: 100%; }
  .api-key-secret .copy-field { display: grid; }
  .drawer-scroll { padding: 24px 20px 35px; }
  .drawer-header { height: 62px; padding-inline: 18px; }
  .drawer-details { grid-template-columns: 1fr 1fr; }
  .screenshot-grid { grid-template-columns: 1fr; }
  .status-action { align-items: flex-start; flex-direction: column; }
  .status-action .button { width: 100%; }
  .toast-stack { right: 12px; bottom: calc(76px + env(safe-area-inset-bottom)); width: calc(100% - 24px); }
}

@media (max-width: 390px) {
  .summary-card { display: grid; justify-items: start; }
  .summary-icon { display: none; }
  .summary-card div span { font-size: 8px; }
  .toolbar-actions .compact-select { display: none; }
  .drawer-details { grid-template-columns: 1fr; }
}

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