:root {
  --font-ui: "Manrope", "Segoe UI", sans-serif;
  --font-display: "Space Grotesk", "Manrope", sans-serif;
  --bg-0: #090b14;
  --bg-1: #11182a;
  --bg-2: #1a2442;
  --surface: #0f162c;
  --surface-strong: #111d3a;
  --surface-soft: #0c1326;
  --line: #2a3a67;
  --line-soft: #1f2c52;
  --text-main: #eff5ff;
  --text-dim: #9db0d8;
  --accent: #4ef4c8;
  --accent-alt: #f7ff7f;
  --accent-blue: #77a9ff;
  --danger: #ff5f7f;
  --danger-soft: #2a1120;
  --shadow-lg: 0 24px 60px rgba(1, 4, 16, 0.55);
  --radius-xl: 26px;
  --radius-md: 16px;
  --bottom-nav-height: 86px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-ui);
  color: var(--text-main);
  background:
    radial-gradient(1100px 620px at 12% -5%, rgba(78, 244, 200, 0.2), transparent 58%),
    radial-gradient(900px 560px at 95% 110%, rgba(119, 169, 255, 0.24), transparent 62%),
    radial-gradient(650px 400px at 80% -8%, rgba(247, 255, 127, 0.09), transparent 60%),
    linear-gradient(158deg, var(--bg-0) 0%, var(--bg-1) 45%, var(--bg-2) 100%);
}

.page-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(circle at 1px 1px, rgba(161, 185, 235, 0.13) 1px, transparent 0),
    linear-gradient(135deg, rgba(78, 244, 200, 0.06) 0%, rgba(119, 169, 255, 0.04) 100%);
  background-size: 30px 30px, 100% 100%;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.95), rgba(0, 0, 0, 0.65));
}

.app-shell {
  position: relative;
  width: min(980px, 94vw);
  margin: 22px auto;
  min-height: calc(100vh - 44px);
  min-height: calc(100dvh - 44px);
  padding: 18px;
  padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 22px);
  border-radius: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  animation: shell-in 360ms ease-out;
}

.auth-screen {
  display: grid;
  gap: 14px;
}

#installButton:not(.hidden) {
  display: none;
}

.auth-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(165deg, rgba(19, 29, 56, 0.95) 0%, rgba(13, 20, 39, 0.95) 100%);
  padding: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

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

.auth-status {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-dim);
}

.auth-status:empty {
  display: none;
}

.auth-status.auth-status-error {
  color: #ffb5ca;
}

.auth-status.auth-status-success {
  color: #b8fff1;
}

.auth-status.auth-status-info {
  color: #b8d4ff;
}

#resendVerificationButton {
  grid-column: 1 / -1;
}

body.mode-auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}

body.mode-auth .app-shell {
  width: min(560px, 92vw);
  min-height: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

body.mode-auth .auth-screen {
  width: 100%;
}

body.mode-auth .auth-panel {
  padding: 16px;
  border-radius: 18px;
}

body.mode-auth .auth-form {
  grid-template-columns: 1fr;
  gap: 10px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  color: var(--text-main);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: linear-gradient(180deg, #111a34 0%, #0d1530 100%);
}

input::placeholder,
select {
  color: var(--text-dim);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(119, 169, 255, 0.2);
}

.btn {
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, border-color 140ms ease, background 140ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  color: #071013;
  border-color: rgba(247, 255, 127, 0.55);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
  box-shadow: 0 10px 24px rgba(78, 244, 200, 0.32);
}

.btn-primary:hover {
  box-shadow: 0 14px 26px rgba(78, 244, 200, 0.42);
}

.btn-secondary {
  background: linear-gradient(165deg, #18274d 0%, #111d3b 100%);
  border-color: #35508b;
  color: #c6d9ff;
}

.btn-secondary:hover {
  border-color: #4a6ab4;
  color: #eff6ff;
}

.btn-danger-soft {
  background: linear-gradient(165deg, #311329 0%, #251022 100%);
  border-color: #7f3658;
  color: #ff8aaa;
}

.btn-danger-soft:hover {
  border-color: #a44673;
  color: #ffd2df;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.tabs-row {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7000;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding: 9px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(109, 139, 211, 0.35);
  background:
    linear-gradient(180deg, rgba(8, 12, 24, 0.78) 0%, rgba(8, 11, 22, 0.95) 100%);
  backdrop-filter: blur(12px);
  box-shadow: 0 -12px 28px rgba(0, 0, 0, 0.38);
}

#appScreen {
  position: relative;
  padding-top: 58px;
}

.account-menu-wrap {
  position: absolute;
  top: 0;
  left: 12px;
  z-index: 6400;
}

.account-menu-button {
  border-radius: 12px;
}

.account-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  width: min(260px, 72vw);
  padding: 10px;
  border: 1px solid rgba(106, 137, 206, 0.44);
  border-radius: 14px;
  background: linear-gradient(165deg, rgba(14, 24, 47, 0.98), rgba(11, 18, 36, 0.98));
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.42);
}

.account-email {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-dim);
  overflow-wrap: anywhere;
}

.account-logout {
  width: 100%;
}

.tab-button {
  border: 1px solid rgba(80, 104, 163, 0.36);
  background: linear-gradient(165deg, rgba(22, 34, 67, 0.78), rgba(14, 24, 48, 0.82));
  color: #a9bde7;
  border-radius: 13px;
  min-height: 58px;
  padding: 6px 8px 7px;
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 0.01em;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 2px;
  cursor: pointer;
}

.tab-button .tab-icon {
  width: 19px;
  height: 19px;
  fill: currentColor;
}

.tab-label {
  font-size: 13px;
}

.tab-button.active {
  color: #041017;
  border-color: rgba(247, 255, 127, 0.65);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-alt) 100%);
  box-shadow: 0 10px 24px rgba(78, 244, 200, 0.26);
}

.tab-button.template-editor-mode {
  color: #ffd7ad;
  border-color: rgba(255, 173, 94, 0.52);
  background: linear-gradient(165deg, rgba(68, 41, 20, 0.8), rgba(41, 24, 12, 0.84));
}

.tab-button.template-editor-mode.active {
  color: #1a1206;
  border-color: rgba(255, 188, 116, 0.74);
  background: linear-gradient(135deg, #ffba72 0%, #ffd77f 100%);
  box-shadow: 0 10px 24px rgba(255, 183, 98, 0.28);
}

.tab-button:disabled,
.tab-button.disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.panel {
  padding: 12px;
  border: none;
  border-radius: 0;
  background: transparent;
  animation: panel-in 260ms ease-out;
}

.checklist-header {
  padding: 4px 0 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.checklist-title {
  margin: 0;
  min-width: 0;
  flex: 1;
  font-family: var(--font-display);
  font-size: clamp(26px, 2.8vw, 36px);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #f4f8ff;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.icon-btn {
  width: 46px;
  min-width: 46px;
  height: 46px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.icon-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.status-line {
  margin: 10px 2px;
  font-size: 14px;
  color: var(--text-dim);
}

.add-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.create-list-form {
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 220px) auto;
}

.split-columns {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.panel.template-editor-mode .split-columns {
  grid-template-columns: 1fr;
}

.task-box.template-open-box {
  grid-column: 1 / -1;
}

.task-box {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  background:
    linear-gradient(170deg, rgba(21, 34, 66, 0.96) 0%, rgba(13, 23, 46, 0.94) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.box-title {
  margin: 0;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: #c7d7fc;
}

.box-count {
  font-size: 12px;
  color: #7fa0da;
  letter-spacing: 0.03em;
}

.item-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 9px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 11px 12px;
  background: linear-gradient(180deg, #162445 0%, #121d39 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.item label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.item input[type="checkbox"] {
  accent-color: var(--accent);
}

.item span {
  color: #edf4ff;
  overflow-wrap: anywhere;
}

.item.done span {
  text-decoration: line-through;
  color: #8ea3ce;
}

.row-button {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(170deg, rgba(22, 35, 67, 0.96), rgba(14, 24, 48, 0.95));
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.row-interactive {
  cursor: pointer;
}

.row-interactive:focus-visible {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(119, 169, 255, 0.24);
}

.row-button > div:first-child {
  min-width: 0;
}

.row-button:hover {
  border-color: #4f6dab;
  box-shadow: 0 12px 20px rgba(2, 8, 22, 0.35);
}

.row-button-shared {
  border-color: rgba(78, 244, 200, 0.58);
  background: linear-gradient(170deg, rgba(18, 44, 56, 0.95), rgba(11, 29, 46, 0.94));
}

.row-button-shared:hover {
  border-color: rgba(112, 255, 220, 0.88);
  box-shadow: 0 12px 22px rgba(6, 33, 39, 0.45);
}

.panel-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(22px, 2vw, 30px);
  letter-spacing: -0.015em;
}

.list-badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  font-family: var(--font-ui);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.list-badge.shared {
  background: rgba(78, 244, 200, 0.18);
  border: 1px solid rgba(78, 244, 200, 0.5);
  color: #beffe7;
}

.row-meta {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-dim);
}

.my-list-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.my-list-actions .icon-btn {
  width: 44px;
  min-width: 44px;
  height: 44px;
}

.empty-card {
  border: 1px dashed #3b4f80;
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  color: #a7b8df;
  background: linear-gradient(180deg, rgba(17, 28, 57, 0.9), rgba(13, 22, 45, 0.92));
}

.toast-wrap {
  position: fixed;
  right: 14px;
  bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 12px);
  display: grid;
  gap: 8px;
  z-index: 9000;
}

.toast {
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 14px;
  border: 1px solid;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.42);
}

.toast-info {
  background: #13284a;
  border-color: #2d5698;
  color: #b8d4ff;
}

.toast-success {
  background: #0f3a37;
  border-color: #2f8f7f;
  color: #b8fff1;
}

.toast-error {
  background: #3a1328;
  border-color: #8f365f;
  color: #ffc1d8;
}

.hidden {
  display: none;
}

@keyframes shell-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.992);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 860px) {
  .auth-form {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  #installButton:not(.hidden) {
    display: block;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: 100vw;
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 8px;
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom) + 10px);
  }

  #appScreen {
    padding-top: 50px;
  }

  .account-menu-wrap {
    top: 0;
    left: 8px;
  }

  .panel {
    padding: 8px;
  }

  .checklist-header {
    padding: 2px 0 10px;
  }

  .tab-button {
    min-height: 56px;
    border-radius: 12px;
  }

  .tab-label {
    font-size: 12px;
  }

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

  .create-list-form {
    grid-template-columns: minmax(0, 1fr) minmax(110px, 42%) auto;
  }

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

  .row-button {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .my-list-actions {
    width: auto;
    margin-left: auto;
    justify-content: flex-end;
  }

  .tabs-row {
    gap: 8px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }
}

@media (max-width: 420px) {
  .checklist-title {
    font-size: clamp(22px, 7.4vw, 30px);
  }

  .create-list-form {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-shell,
  .panel,
  .btn {
    animation: none !important;
    transition: none !important;
  }
}
