:root {
  color-scheme: light;
  --sidebar-width: 280px;
  --sidebar-offset: 280px;
  --preview-width: 390px;
  --bg: #eef6ff;
  --surface: #ffffff;
  --surface-soft: #f4f8ff;
  --surface-strong: #e5f2ff;
  --ink: #09111f;
  --muted: #5f6f86;
  --line: #cbdaf2;
  --teal: #00a8b8;
  --teal-dark: #007684;
  --amber: #e0a114;
  --rose: #d94678;
  --blue: #315cf6;
  --green: #16a56a;
  --violet: #8b5cf6;
  --electric: #00d4ff;
  --shadow: 0 22px 50px rgba(49, 92, 246, 0.16);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b16;
  --surface: #111827;
  --surface-soft: #151f33;
  --surface-strong: #102f44;
  --ink: #f4f8ff;
  --muted: #a9b8d0;
  --line: #263c60;
  --teal: #00d4ff;
  --teal-dark: #80ecff;
  --amber: #ffbf38;
  --rose: #ff5c93;
  --blue: #7aa2ff;
  --green: #49df8f;
  --violet: #ad8cff;
  --electric: #00d4ff;
  --shadow: 0 22px 50px rgba(0, 212, 255, 0.14);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --bg: #15181c;
    --surface: #20262c;
    --surface-soft: #262d34;
    --surface-strong: #163431;
    --ink: #eef2f5;
    --muted: #aab4bf;
    --line: #38434f;
    --teal: #2bb3a4;
    --teal-dark: #60d3c7;
    --amber: #e3a138;
    --rose: #ee6c8a;
    --blue: #7da2ff;
    --green: #58c77a;
    --shadow: 0 22px 50px rgba(0, 0, 0, 0.32);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-width: 320px;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(0, 212, 255, 0.14), rgba(139, 92, 246, 0.08) 42%, rgba(255, 183, 3, 0.12)),
    var(--bg);
  color: var(--ink);
}

:root[data-theme="dark"] body {
  background:
    linear-gradient(180deg, rgba(43, 179, 164, 0.08), rgba(0, 0, 0, 0)),
    var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] body {
    background:
      linear-gradient(180deg, rgba(43, 179, 164, 0.08), rgba(0, 0, 0, 0)),
      var(--bg);
  }
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

a {
  color: var(--teal-dark);
}

.auth-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(980px, 100%);
}

.auth-brand {
  margin-bottom: 18px;
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.92fr);
  gap: 14px;
}

.auth-grid-single {
  grid-template-columns: minmax(280px, 520px);
  justify-content: center;
}

.auth-card {
  display: grid;
  align-content: start;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  padding: 24px;
}

.auth-card h1,
.auth-card h2 {
  margin: 0;
  line-height: 1.05;
}

.auth-card h1 {
  font-size: 2.3rem;
}

.auth-card h2 {
  font-size: 1.5rem;
}

.hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.app-shell {
  display: grid;
  min-height: 100vh;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  transition: grid-template-columns 180ms ease;
}

.app-shell.sidebar-collapsed {
  grid-template-columns: 0 minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  overflow: hidden;
  display: flex;
  width: var(--sidebar-width);
  max-width: var(--sidebar-width);
  min-width: 0;
  height: 100vh;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--surface-soft) 88%, transparent)),
    var(--surface);
  padding: 24px 18px;
  backdrop-filter: blur(16px);
  transition:
    width 180ms ease,
    max-width 180ms ease,
    padding 180ms ease,
    opacity 160ms ease;
}

.sidebar-collapsed .sidebar {
  width: 0;
  max-width: 0;
  min-width: 0;
  padding-right: 0;
  padding-left: 0;
  border-right: 0;
  opacity: 0;
  pointer-events: none;
}

.sidebar-collapsed .sidebar-resize-handle {
  display: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -6px;
  bottom: 0;
  z-index: 3;
  width: 12px;
  cursor: ew-resize;
}

.sidebar-resize-handle::after {
  position: absolute;
  top: 18px;
  right: 5px;
  bottom: 18px;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--electric), var(--violet), var(--amber));
  content: "";
  opacity: 0.62;
}

:root[data-theme="dark"] .brand-logo {
  filter: drop-shadow(0 0 10px rgba(0, 212, 255, 0.22));
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] .brand-logo {
    filter: drop-shadow(0 0 10px rgba(0, 212, 255, 0.22));
  }
}

.brand strong,
.brand > div span {
  display: block;
}

.brand > div span,
.eyebrow {
  color: var(--muted);
  font-size: 0.78rem;
}

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

.nav-item,
.secondary-action,
.primary-action,
.danger-action,
.text-action,
.icon-button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-color: var(--line);
  background: var(--surface);
  color: var(--muted);
  padding: 0 12px;
  text-align: left;
}

.nav-item.active {
  border-color: color-mix(in srgb, var(--teal) 42%, var(--line));
  background: var(--surface-strong);
  color: var(--teal-dark);
}

.nav-item strong {
  min-width: 26px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 22px;
  text-align: center;
}

.sidebar-section {
  display: grid;
  gap: 10px;
}

.sidebar-section h2,
.calendar-toolbar h2,
.section-heading h2,
.section-heading h3 {
  margin: 0;
  font-size: 0.96rem;
}

.field-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

select,
input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

select,
input {
  height: 40px;
  padding: 0 11px;
}

input[type="color"] {
  padding: 4px;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
}

textarea {
  resize: vertical;
  padding: 10px 11px;
}

select:focus,
input:focus,
textarea:focus {
  border-color: color-mix(in srgb, var(--teal) 70%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 16%, transparent);
}

.workspace {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: 2.45rem;
  line-height: 1.05;
}

.eyebrow {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  width: min(620px, 100%);
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
}

.search-box {
  width: min(420px, 100%);
}

.primary-action {
  background: linear-gradient(135deg, var(--blue), var(--violet), var(--teal));
  color: #fff;
  padding: 0 15px;
  white-space: nowrap;
}

.primary-action:hover {
  background: color-mix(in srgb, var(--teal) 78%, #000);
}

.secondary-action,
.file-action {
  display: inline-grid;
  place-items: center;
  border-color: var(--line);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, var(--electric)), var(--surface));
  color: var(--ink);
  padding: 0 12px;
  text-align: center;
  text-decoration: none;
}

.secondary-action:hover,
.icon-button:hover,
.nav-item:hover {
  border-color: color-mix(in srgb, var(--teal) 34%, var(--line));
  background: var(--surface-strong);
}

.danger-action {
  border-color: color-mix(in srgb, var(--rose) 35%, var(--line));
  background: color-mix(in srgb, var(--rose) 12%, var(--surface));
  color: var(--rose);
  padding: 0 12px;
}

.text-action {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.home-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

.home-hero > div,
.clock-card,
.panel-section,
.quick-stats article,
.column {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}

.home-hero > div:first-child {
  padding: 22px;
}

.home-hero h2 {
  margin: 6px 0 8px;
  font-size: 2rem;
  line-height: 1.1;
}

.home-hero p:last-child {
  margin: 0;
  color: var(--muted);
}

.clock-card {
  display: grid;
  align-content: center;
  padding: 22px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--electric) 13%, var(--surface)), color-mix(in srgb, var(--amber) 12%, var(--surface))),
    var(--surface);
}

.clock-card strong {
  font-size: 2.3rem;
  line-height: 1;
}

.clock-card span {
  margin-top: 8px;
  color: var(--muted);
}

.quick-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.quick-stats article {
  min-height: 76px;
  padding: 12px;
}

.quick-stats span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
}

.quick-stats strong {
  display: block;
  margin-top: 4px;
  font-size: 1.7rem;
}

.home-grid,
.settings-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.settings-layout {
  grid-template-columns: minmax(0, 1fr);
}

.panel-section {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 14px;
}

.notes-panel {
  min-height: 100%;
}

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

.note-toolbar .icon-button {
  width: 36px;
  min-height: 36px;
  font-size: 0.92rem;
  font-weight: 800;
}

.note-editor {
  min-height: 180px;
  max-height: 360px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 12px;
  outline: none;
}

.note-editor:empty::before {
  color: var(--muted);
  content: "Szybkie notatki dla aktywnego profilu...";
}

.note-editor:focus {
  border-color: color-mix(in srgb, var(--teal) 70%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--teal) 16%, transparent);
}

.note-editor h3,
.note-editor p,
.note-editor ul,
.note-editor ol {
  margin: 0 0 8px;
}

.note-editor ul,
.note-editor ol {
  padding-left: 22px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading span {
  min-width: 28px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 24px;
  text-align: center;
}

.compact-task-list,
.cloud-file-list,
.settings-list,
.user-list,
.attachment-list {
  display: grid;
  gap: 8px;
}

.cloud-upload {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.cloud-upload span {
  color: var(--muted);
  font-size: 0.82rem;
}

.cloud-file-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.cloud-file-row strong,
.cloud-file-row span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-file-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.cloud-disabled {
  opacity: 0.72;
}

.compact-task {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 6px 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 10px;
  text-align: left;
}

.compact-task strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-task span:last-child {
  grid-column: 2;
  color: var(--muted);
  font-size: 0.78rem;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.board {
  display: flex;
  align-items: stretch;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.column {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  min-width: 250px;
  min-height: 520px;
  flex-direction: column;
  background: color-mix(in srgb, var(--surface-soft) 86%, transparent);
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 4px solid var(--teal);
  border-bottom: 1px solid var(--line);
  padding: 12px;
}

.column-header h2 {
  margin: 0;
  font-size: 0.95rem;
}

.column-header span {
  min-width: 28px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 24px;
  text-align: center;
}

.task-list {
  display: grid;
  min-height: 440px;
  align-content: start;
  gap: 10px;
  padding: 12px;
}

.column-resize {
  position: absolute;
  top: 0;
  right: -6px;
  bottom: 0;
  z-index: 1;
  width: 12px;
  cursor: ew-resize;
}

.column-resize::after {
  position: absolute;
  top: 16px;
  right: 5px;
  bottom: 16px;
  width: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 34%, transparent);
  content: "";
  opacity: 0;
  transition: opacity 160ms ease;
}

.column-resize:hover::after {
  opacity: 1;
}

.task-card {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--teal);
  border-radius: 8px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--priority-color, var(--teal)) 13%, transparent), transparent 52%),
    var(--surface);
  color: var(--ink);
  padding: 12px;
  text-align: left;
  box-shadow: 0 10px 24px rgba(30, 37, 45, 0.06);
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    border-color 120ms ease;
}

.task-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(30, 37, 45, 0.1);
}

.priority-card-high {
  --priority-color: var(--rose);
}

.priority-card-medium {
  --priority-color: var(--amber);
}

.priority-card-low {
  --priority-color: var(--green);
}

.task-card[draggable="true"] {
  cursor: grab;
}

.task-card.dragging {
  opacity: 0.45;
}

.task-card.task-overdue,
.calendar-task.task-overdue {
  border-color: color-mix(in srgb, var(--rose) 82%, var(--line));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--rose) 18%, transparent);
}

.task-card h3 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.25;
}

.task-meta,
.task-tags,
.task-progress {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.task-meta span,
.tag,
.priority-pill,
.date-pill {
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 22px;
  padding: 0 8px;
}

.tag {
  border: 1px solid color-mix(in srgb, var(--tag-color, var(--line)) 35%, var(--line));
}

.done-tag {
  --tag-color: var(--green);
}

.priority-high,
.date-overdue {
  background: color-mix(in srgb, var(--rose) 14%, var(--surface));
  color: var(--rose);
}

.priority-medium {
  background: color-mix(in srgb, var(--amber) 14%, var(--surface));
  color: var(--amber);
}

.priority-low {
  background: color-mix(in srgb, var(--green) 14%, var(--surface));
  color: var(--green);
}

.date-today {
  background: color-mix(in srgb, var(--rose) 18%, var(--surface));
  color: var(--rose);
}

.progress-track {
  position: relative;
  height: 7px;
  flex: 1 1 120px;
  overflow: hidden;
  border-radius: 999px;
  background: color-mix(in srgb, var(--ink) 9%, transparent);
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.checklist-hint {
  margin: 0;
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 0.78rem;
  padding: 8px;
}

.empty-state {
  display: grid;
  min-height: 94px;
  place-items: center;
  border: 1px dashed color-mix(in srgb, var(--muted) 42%, var(--line));
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 4px 0 14px;
}

.icon-button {
  display: grid;
  width: 40px;
  place-items: center;
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 1.15rem;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.calendar-weekdays {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.calendar-weekdays span {
  padding: 0 8px 8px;
}

.calendar-grid {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.calendar-day {
  display: flex;
  min-height: 128px;
  flex-direction: column;
  gap: 6px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 8px;
}

.calendar-day:nth-child(7n) {
  border-right: 0;
}

.calendar-day.muted {
  background: color-mix(in srgb, var(--surface-soft) 72%, transparent);
  color: color-mix(in srgb, var(--muted) 72%, transparent);
}

.calendar-day.weekend {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--violet) 8%, transparent), transparent),
    color-mix(in srgb, var(--surface-soft) 62%, var(--surface));
}

.calendar-day.weekend.muted {
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--violet) 6%, transparent), transparent),
    color-mix(in srgb, var(--surface-soft) 78%, transparent);
}

.calendar-day.today {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--teal) 58%, transparent);
}

.day-number {
  font-weight: 800;
  line-height: 1;
}

.calendar-drop-zone {
  display: grid;
  min-height: 86px;
  align-content: start;
  gap: 5px;
}

.calendar-drop-zone:empty {
  border-radius: 6px;
}

.calendar-task {
  display: grid;
  gap: 2px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left: 3px solid var(--teal);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.76rem;
  line-height: 1.25;
  padding: 5px 6px;
  text-align: left;
  text-overflow: ellipsis;
}

.calendar-task strong,
.calendar-task span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calendar-task span {
  color: var(--muted);
  font-size: 0.68rem;
}

.settings-row {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 52px minmax(100px, auto) 40px 40px auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px;
}

#profileSettingsList .settings-row {
  grid-template-columns: minmax(160px, 1fr) 52px auto auto;
}

#statusSettingsList .settings-row {
  grid-template-columns: minmax(160px, 1fr) 52px 92px minmax(72px, auto) 40px 40px auto auto;
}

#labelSettingsList .settings-row {
  grid-template-columns: minmax(160px, 1fr) 52px auto auto;
}

.status-width {
  min-width: 92px;
}

.inline-settings-form,
.user-form,
.password-form,
.settings-actions,
.weather-form,
.storage-form,
.ai-form {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 52px minmax(120px, auto) auto;
  gap: 8px;
  align-items: center;
}

.password-form,
.settings-actions,
.weather-form,
.storage-form,
.ai-form {
  grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
}

.settings-actions {
  grid-template-columns: repeat(2, minmax(0, auto));
  justify-content: start;
}

.weather-form {
  grid-template-columns: minmax(0, 1fr) auto;
}

.storage-form {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.storage-form label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.82rem;
}

.storage-explainer,
.storage-hint {
  border: 1px solid color-mix(in srgb, var(--teal) 22%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--teal) 8%, var(--surface));
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.35;
  padding: 10px;
}

.storage-explainer strong,
.storage-explainer span {
  display: block;
}

.storage-explainer strong {
  margin-bottom: 3px;
  color: var(--ink);
}

.storage-hint {
  margin-top: 6px;
  padding: 8px;
}

.local-directory-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.local-directory-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.ai-form {
  grid-template-columns: 150px minmax(180px, 1fr) minmax(130px, 0.7fr) auto;
}

.template-form,
.template-row {
  display: grid;
  gap: 8px;
}

.template-row {
  grid-template-columns: minmax(150px, 0.6fr) minmax(220px, 1fr) auto auto;
}

.user-form {
  grid-template-columns: repeat(3, minmax(0, 1fr)) auto auto auto;
}

.inline-check {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.user-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.editable-user-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(140px, 0.9fr) minmax(130px, 0.8fr) auto auto auto auto;
  gap: 8px;
  align-items: center;
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.task-dialog,
.settings-dialog,
.quick-task-dialog {
  width: min(860px, calc(100vw - 28px));
  max-height: calc(100vh - 32px);
  border: 0;
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 0;
}

.settings-dialog {
  width: min(1040px, calc(100vw - 28px));
}

.quick-task-dialog {
  width: min(560px, calc(100vw - 28px));
}

.task-preview-stack {
  position: fixed;
  z-index: 4;
  top: 18px;
  right: auto;
  bottom: 18px;
  left: calc(var(--sidebar-offset, var(--sidebar-width)) + 18px);
  display: flex;
  align-items: stretch;
  gap: 12px;
  width: max-content;
  max-width: calc(100vw - var(--sidebar-offset, var(--sidebar-width)) - 36px);
  overflow-x: auto;
  padding-left: 4px;
  pointer-events: none;
}

.task-preview {
  position: relative;
  display: grid;
  width: var(--preview-width);
  min-width: 320px;
  max-width: 820px;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 16px;
  transition:
    width 120ms ease;
  pointer-events: auto;
}

.preview-resize-handle {
  position: absolute;
  top: 0;
  right: -6px;
  bottom: 0;
  width: 14px;
  cursor: ew-resize;
}

.preview-resize-handle::after {
  position: absolute;
  top: 18px;
  right: 6px;
  bottom: 18px;
  width: 2px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 38%, transparent);
  content: "";
  opacity: 0;
  transition: opacity 160ms ease;
}

.task-preview:hover .preview-resize-handle::after {
  opacity: 1;
}

.task-preview[draggable="true"] {
  cursor: grab;
}

.task-preview.dragging {
  opacity: 0.52;
}

.task-preview header,
.task-preview footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-preview h2 {
  margin: 2px 0 0;
  font-size: 1.35rem;
  line-height: 1.15;
}

.preview-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.preview-section {
  display: grid;
  min-height: 0;
  align-content: start;
  gap: 10px;
}

.preview-checklist {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}

.preview-check-item {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 10px;
}

.preview-check-item.date-today,
.preview-check-item.date-overdue {
  border-color: color-mix(in srgb, var(--rose) 58%, var(--line));
  background: color-mix(in srgb, var(--rose) 12%, var(--surface));
}

.preview-check-item span,
.preview-check-item strong,
.preview-check-item small {
  display: block;
}

.preview-check-item small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.76rem;
}

.preview-notes {
  overflow: auto;
  max-height: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  padding: 10px;
  font-size: 0.88rem;
  line-height: 1.45;
}

.task-dialog::backdrop,
.settings-dialog::backdrop,
.quick-task-dialog::backdrop {
  background: rgba(30, 37, 45, 0.46);
  backdrop-filter: blur(4px);
}

.task-editor,
.settings-editor,
.quick-task-editor {
  display: grid;
  gap: 18px;
  padding: 20px;
}

.task-editor header,
.task-editor footer,
.settings-editor header,
.quick-task-editor header,
.quick-task-editor footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.task-editor h2,
.settings-editor h2,
.quick-task-editor h2 {
  margin: 2px 0 0;
  font-size: 1.35rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.label-picker,
.checklist-editor,
.attachments-editor {
  display: grid;
  gap: 10px;
}

.template-loader {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

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

.label-option {
  display: flex;
  width: auto;
  align-items: center;
  gap: 6px;
  border: 1px solid color-mix(in srgb, var(--tag-color) 38%, var(--line));
  border-radius: 999px;
  background: color-mix(in srgb, var(--tag-color) 10%, var(--surface));
  color: var(--ink);
  padding: 7px 10px;
}

#checklistItems {
  display: grid;
  gap: 8px;
}

.checklist-row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 8px;
}

.checklist-row.date-today,
.checklist-row.date-overdue {
  border-color: color-mix(in srgb, var(--rose) 58%, var(--line));
  background: color-mix(in srgb, var(--rose) 12%, var(--surface));
}

.checklist-row input[type="text"] {
  border-color: transparent;
  background: transparent;
}

.checklist-row input[type="text"]:focus {
  background: var(--surface);
}

.checklist-remove {
  min-height: 32px;
  border: 1px solid color-mix(in srgb, var(--rose) 38%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--rose) 10%, var(--surface));
  color: var(--rose);
  font-weight: 800;
}

.inline-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.checklist-add {
  grid-template-columns: minmax(0, 1fr) auto;
}

.task-card.local-locked,
.calendar-task.local-locked,
.attachment-row.local-unavailable {
  opacity: 0.48;
  filter: grayscale(0.7);
  cursor: not-allowed;
}

.attachment-disabled-name {
  overflow: hidden;
  color: var(--muted);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lock-pill {
  border-color: color-mix(in srgb, var(--rose) 30%, var(--line));
  background: color-mix(in srgb, var(--rose) 12%, var(--surface));
  color: var(--rose);
}

.attachment-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 8px;
}

.attachment-row a {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-actions {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.attachment-actions strong {
  overflow: hidden;
  max-width: 220px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attachment-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 5;
  max-width: min(360px, calc(100vw - 40px));
  transform: translateY(18px);
  border-radius: 8px;
  background: var(--ink);
  color: var(--surface);
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.loading-indicator {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 7;
  width: 34px;
  height: 34px;
  border: 3px solid color-mix(in srgb, var(--electric) 20%, transparent);
  border-top-color: var(--amber);
  border-right-color: var(--violet);
  border-radius: 50%;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  box-shadow: var(--shadow);
  animation: spin 760ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .workspace {
    margin-right: 0;
  }

  .task-preview-stack {
    top: auto;
    right: 12px;
    bottom: 12px;
    left: 12px;
    width: auto;
    max-width: none;
    max-height: 68vh;
  }

  .sidebar {
    position: static;
    width: 100%;
    max-width: none;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .brand {
    flex: 1 1 240px;
  }

  .nav {
    flex: 2 1 460px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .sidebar-section {
    flex: 1 1 220px;
  }

  .home-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .auth-view,
  .workspace,
  .sidebar {
    padding: 16px;
  }

  .auth-grid,
  .editable-user-row,
  .user-form,
  .home-hero,
  .topbar,
  .topbar-actions,
  .task-editor header,
  .task-editor footer {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .topbar h1 {
    font-size: 1.9rem;
  }

  .search-box,
  .topbar-actions {
    width: 100%;
  }

  .quick-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav {
    grid-template-columns: 1fr;
  }

  .form-grid,
  .inline-add,
  .checklist-add,
  .settings-row,
  #profileSettingsList .settings-row,
  #statusSettingsList .settings-row,
  #labelSettingsList .settings-row,
  .inline-settings-form,
  .password-form,
  .settings-actions,
  .weather-form,
  .storage-form,
  .ai-form,
  .template-loader,
  .template-row,
  .user-form,
  .attachment-row,
  .cloud-file-row {
    grid-template-columns: 1fr;
  }

  .calendar-weekdays {
    display: none;
  }

  .calendar-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .calendar-day {
    min-height: 74px;
    border-right: 0;
  }

  .checklist-row {
    grid-template-columns: 26px minmax(0, 1fr) 38px;
  }

  .checklist-row button {
    grid-column: 3;
  }
}
