:root {
  font-family: 'Inter', system-ui, sans-serif;
  color: #e2e8f0;
  line-height: 1.6;
  --status-bar: #030310;
  --page-bg-solid: #020617;
  --page-bg: linear-gradient(180deg, #070b1e 0%, #0f172a 60%, #020617 100%);
  --panel-bg: rgba(15, 23, 42, 0.9);
  --panel-border: rgba(148, 163, 184, 0.4);
  --panel-shadow: 0 12px 32px rgba(2, 6, 23, 0.6);
  --text-primary: #e2e8f0;
  --text-muted: #94a3b8;
  --heading-color: #f8fafc;
  --button-bg: #2563eb;
  --button-bg-hover: #1d4ed8;
  --button-ghost-bg: rgba(15, 23, 42, 0.65);
  --button-ghost-border: rgba(148, 163, 184, 0.35);
  --button-ghost-hover: rgba(148, 163, 184, 0.25);
  --checkbox-border: rgba(148, 163, 184, 0.65);
  --checkbox-bg: rgba(2, 6, 23, 0.9);
  --list-row-bg: rgba(15, 23, 42, 0.85);
  --list-row-hover: rgba(59, 130, 246, 0.18);
  --list-text: #e2e8f0;
  --list-gap: 0.12rem;
  --status-online-bg: rgba(34, 197, 94, 0.18);
  --status-online-border: rgba(34, 197, 94, 0.8);
  --status-online-fg: #86efac;
  --status-connecting-bg: rgba(245, 158, 11, 0.18);
  --status-connecting-border: rgba(245, 158, 11, 0.85);
  --status-connecting-fg: #fbbf24;
  --status-disconnected-bg: rgba(239, 68, 68, 0.18);
  --status-disconnected-border: rgba(239, 68, 68, 0.85);
  --status-disconnected-fg: #fca5a5;
  --status-warn-bg: var(--status-disconnected-bg);
  --status-warn-border: var(--status-disconnected-border);
  --status-idle-bg: var(--status-connecting-bg);
  --status-idle-border: var(--status-connecting-border);
  --status-idle-fg: var(--status-connecting-fg);
  --list-item-font-size: 0.95rem;
  --list-item-line-height: 1.3;
  --editor-font-size: 1rem;
  --editor-line-height: 1.4;
}

html[data-font-size='medium'] {
  --list-item-font-size: 1.12rem;
  --list-item-line-height: 1.35;
  --editor-font-size: 1.16rem;
  --editor-line-height: 1.44;
}

html[data-font-size='large'] {
  --list-item-font-size: 1.26rem;
  --list-item-line-height: 1.4;
  --editor-font-size: 1.3rem;
  --editor-line-height: 1.47;
}

html[data-ui-show-edit-button='false'] #toggle-mode,
html[data-ui-show-delete-button='false'] #delete-checked-button {
  display: none !important;
}

html[data-ui-show-edit-button='true'] #toggle-mode {
  display: inline-flex !important;
}

html[data-ui-add-button='titlebar'] #titlebar-add-button,
html[data-ui-add-button='left'] #floating-add-button,
html[data-ui-add-button='right'] #floating-add-button {
  display: inline-flex !important;
}

html[data-ui-add-button='left'] #floating-add-button {
  left: calc(0.65rem + env(safe-area-inset-left));
  right: auto;
}

html[data-ui-add-button='right'] #floating-add-button {
  right: calc(0.55rem + env(safe-area-inset-right));
  left: auto;
}

html[data-start-screen='landing'] .app-shell {
  display: none !important;
}

html[data-start-screen='landing'] .landing-screen {
  display: flex !important;
}

html[data-start-screen='landing'] .add-floating {
  display: none !important;
}

html {
  background-color: var(--page-bg-solid, #020617);
  overscroll-behavior: contain;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--page-bg);
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: calc(1rem + env(safe-area-inset-top));
  padding-bottom: calc(1.2rem + env(safe-area-inset-bottom));
  padding-left: calc(0.5rem + env(safe-area-inset-left));
  padding-right: calc(0.5rem + env(safe-area-inset-right));
  box-sizing: border-box;
}

body.landing-open {
  align-items: center;
  justify-content: center;
}

body.auth-locked {
  align-items: center;
  justify-content: center;
}

body.auth-locked .app-shell,
body.auth-locked .landing-screen {
  display: none;
}

body.auth-locked .login-screen.hidden {
  display: flex !important;
}

body.landing-open .app-shell {
  display: none;
}

body.landing-open .add-floating,
body.auth-locked .add-floating {
  display: none !important;
}

.app-shell {
  width: min(960px, 100%);
  max-width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  padding-top: env(safe-area-inset-top);
}

.landing-screen {
  width: min(520px, 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-screen {
  width: min(420px, 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.35rem 1.2rem;
  border-radius: 1.2rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-field {
  width: 100%;
}

.login-field input {
  width: 100%;
  border-radius: 0.75rem;
  padding: 0.55rem 0.75rem;
  font-size: 16px;
  font-weight: 600;
  background: var(--checkbox-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  font-family: inherit;
}

.login-error {
  margin: 0;
  color: var(--status-disconnected-fg);
  font-size: 0.92rem;
}

.login-form button {
  min-height: 2.6rem;
}

.landing-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
  padding: 1.35rem 1.2rem;
  border-radius: 1.2rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
}

.landing-copy h1 {
  margin: 0 0 0.35rem;
  color: var(--heading-color);
  font-size: 1.55rem;
  line-height: 1.15;
}

.landing-copy p {
  margin: 0;
  color: var(--text-muted);
  max-width: 28ch;
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.landing-actions button {
  flex: 1 1 10rem;
  min-width: 0;
}

.landing-join-form {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.landing-join-form input {
  flex: 1;
  min-width: 0;
  font-size: 16px;
}

.landing-share-code-field {
  width: 100%;
  min-width: 0;
}

.landing-join-form button {
  flex: 0 0 auto;
  min-width: 7.5rem;
}

.landing-actions button,
.landing-join-form button {
  min-height: 2.6rem;
}

button {
  border: 1px solid var(--panel-border);
  border-radius: 0.75rem;
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--button-bg);
  color: #fff;
  transition: transform 0.15s ease, background 0.2s ease;
}

button:hover {
  transform: translateY(-1px);
  background: var(--button-bg-hover);
}

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

button.ghost {
  background: var(--button-ghost-bg);
  color: var(--text-primary);
  border-color: var(--button-ghost-border);
}

button.danger {
  background: #dc2626;
  border-color: #dc2626;
}

.icon-button {
  border-radius: 0.85rem;
  width: 40px;
  height: 40px;
  min-width: 40px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Material Symbols Outlined', 'Material Icons', system-ui;
  font-size: 20px;
}

.icon-button.ghost {
  border-color: var(--button-ghost-border);
  background: var(--button-ghost-bg);
}

.icon-button .material-symbols-outlined {
  font-size: 20px;
  color: currentColor;
}

.pane {
  background: transparent;
  border: none;
  box-shadow: none;
}

.single-pane {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.85rem 0.9rem 1rem;
  border-radius: 1.2rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
}

.pane-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  padding: 0 0.25rem;
  flex-wrap: wrap;
}

.title-block {
  flex: 1;
}

.title-line {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.pane-title h2 {
  margin: 0;
  font-size: 1.45rem;
  color: var(--heading-color);
}

.title-actions {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: nowrap;
}

.mode-label {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.pane-divider {
  width: 100%;
  height: 1px;
  background: rgba(148, 163, 184, 0.35);
  margin: 0;
}

.checklist {
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--list-gap);
  width: 100%;
  min-height: 0;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  border-radius: 0.75rem;
  padding: 0.2rem 0.35rem;
  background: var(--list-row-bg);
  color: var(--list-text);
  border: 1px solid transparent;
  transition: background 0.2s ease, border 0.2s ease;
}

.check-row:hover {
  background: var(--list-row-hover);
  border-color: rgba(255, 255, 255, 0.25);
}

.check-row input[type='checkbox'] {
  width: 1rem;
  height: 1rem;
  margin-top: 0;
  accent-color: var(--button-bg);
  border: 1px solid var(--checkbox-border);
  background: var(--checkbox-bg);
}

.item-text {
  font-weight: 600;
  font-size: var(--list-item-font-size);
  line-height: var(--list-item-line-height);
}

.single-edit {
  width: 100%;
  display: block;
  min-height: 14rem;
  border-radius: 0.9rem;
  border: 1px solid var(--panel-border);
  background: var(--checkbox-bg);
  color: var(--text-primary);
  font-size: var(--editor-font-size);
  padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)) 1rem;
  resize: none;
  font-family: 'Inter', system-ui, sans-serif;
  overflow-y: hidden;
  overflow-x: hidden;
  line-height: var(--editor-line-height);
  flex: 0 0 auto;
}

.single-view,
.single-edit {
  transition: opacity 0.2s ease;
}

.hidden {
  display: none !important;
}

.settings-dialog {
  border: none;
  border-radius: 1rem;
  padding: 1.1rem 1.25rem 1.4rem;
  background: var(--panel-bg);
  color: var(--text-primary);
  width: min(360px, 92vw);
  border: 1px solid var(--panel-border);
  max-height: min(85vh, 520px);
  overflow-y: auto;
  scroll-behavior: smooth;
}

.settings-dialog::backdrop {
  background: rgba(2, 6, 23, 0.7);
}

.confirm-dialog {
  border: none;
  border-radius: 1rem;
  padding: 1.05rem 1.15rem 1.1rem;
  background: var(--panel-bg);
  color: var(--text-primary);
  width: min(320px, 88vw);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
}

.confirm-dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
}

.add-dialog {
  border: none;
  border-radius: 1rem;
  padding: 1.05rem 1.15rem 1.1rem;
  background: var(--panel-bg);
  color: var(--text-primary);
  width: min(320px, 88vw);
  border: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
}

.add-dialog::backdrop {
  background: rgba(2, 6, 23, 0.72);
}

.add-form {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.add-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.add-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--heading-color);
}

.add-close {
  width: 36px;
  height: 36px;
}

.add-item-input {
  width: 100%;
  border-radius: 0.75rem;
  padding: 0.6rem 0.8rem;
  font-size: 16px;
  font-weight: 600;
  background: var(--checkbox-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  font-family: inherit;
}

.add-item-input:focus {
  outline: none;
  border-color: var(--button-bg);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.add-multiple-setting {
  align-items: center;
  justify-content: flex-start;
  gap: 0.55rem;
}

.add-multiple-setting input[type='checkbox'] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--button-bg);
}

.add-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: nowrap;
}

.add-actions button {
  min-width: 6rem;
}

.add-actions .add-multiple-setting {
  flex: 1 1 auto;
  margin: 0;
}

.confirm-header h3 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--heading-color);
}

.confirm-body {
  margin: 0.75rem 0 1rem;
  color: var(--text-muted);
}

.confirm-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}

.confirm-actions button {
  min-width: 6.5rem;
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.settings-header h3 {
  margin: 0;
  font-size: 1.1rem;
}

.settings-close {
  width: 36px;
  height: 36px;
}

.settings-body {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  font-weight: 600;
}

.setting.stacked {
  flex-direction: column;
  align-items: flex-start;
  gap: 0.28rem;
}

.setting.keep-bottom {
  margin-top: 0.2rem;
}

.setting select {
  border-radius: 0.65rem;
  padding: 0.35rem 0.7rem;
  background: var(--select-bg, var(--checkbox-bg));
  border: 1px solid var(--select-border, var(--checkbox-border));
  color: var(--text-primary);
  font-family: inherit;
}

.share-actions {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  width: 100%;
}

.share-code-field,
.share-actions input[id='restore-code-input'] {
  flex: 1;
  border-radius: 0.75rem;
  padding: 0.5rem 0.65rem;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--checkbox-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-primary);
  font-family: inherit;
}

.share-code-field {
  flex: 1 1 0;
  width: 100%;
  text-align: center;
  letter-spacing: 0.2em;
}

.share-code-field:focus,
.share-actions input[id='restore-code-input']:focus {
  outline: none;
  border-color: var(--button-bg);
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.share-actions input#restore-code-input {
  flex: 1 1 0;
  min-width: 0;
}

.setting span {
  flex: 1 1 auto;
  min-width: 0;
}

.share-actions button {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  flex: 1 1 0;
  min-width: 58px;
}

.share-copy-button {
  flex: 0 0 auto !important;
  width: 2.4rem;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 !important;
}

.share-copy-button .material-symbols-outlined {
  font-size: 18px;
}

.copy-share-wrap {
  position: relative;
  flex: 0 0 auto;
}

.copy-feedback {
  position: absolute;
  inset: -1px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0.55rem;
  border-radius: 0.9rem;
  background: var(--status-online-bg);
  background:
    linear-gradient(180deg, var(--status-online-bg), color-mix(in srgb, var(--status-online-bg) 70%, transparent));
  border: 1px solid var(--status-online-border);
  color: var(--status-online-fg);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow:
    0 10px 22px rgba(2, 6, 23, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  transform: translateY(1px) scale(0.92);
  opacity: 0;
  transition: opacity 0.16s ease, transform 0.16s ease;
  pointer-events: none;
  z-index: 2;
  backdrop-filter: blur(6px);
  overflow: hidden;
}

.copy-feedback:not(.hidden) {
  opacity: 1;
  transform: translateY(-1px) scale(1);
}

.copy-feedback::before {
  content: 'Copied';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.08;
  font-size: 0.95rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  pointer-events: none;
}

.share-native-button {
  flex: 0 0 auto !important;
  width: 2.4rem;
  min-width: 2.4rem;
  height: 2.4rem;
  padding: 0 !important;
}

.share-native-button .material-symbols-outlined {
  font-size: 18px;
}

.settings-actions {
  margin-top: 0.9rem;
  display: flex;
}

.settings-actions button {
  width: 100%;
}

.settings-divider {
  width: 100%;
  height: 1px;
  background: rgba(148, 163, 184, 0.4);
  margin: 0.85rem 0 0.4rem;
}

.settings-footer-link {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-top: 0.7rem;
  align-self: center;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 999px;
  color: var(--text-muted);
  text-decoration: none;
  background: transparent;
  border: 1px solid transparent;
  opacity: 0.65;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.settings-footer-link:hover {
  opacity: 1;
  background: var(--button-ghost-bg);
  border-color: var(--button-ghost-border);
  color: var(--text-primary);
}

.settings-footer-link .material-symbols-outlined {
  font-size: 20px;
  line-height: 1;
}

.github-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
  display: block;
}

.status-indicator {
  width: 40px;
  height: 40px;
  min-width: 40px;
  border-radius: 0.85rem;
  border: 1px solid var(--status-idle-border);
  background: var(--status-idle-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--status-idle-fg);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.status-indicator[data-status='online'] {
  background: var(--status-online-bg);
  border-color: var(--status-online-border);
  color: var(--status-online-fg);
}

.status-indicator[data-status='idle'] {
  background: var(--status-connecting-bg);
  border-color: var(--status-connecting-border);
  color: var(--status-connecting-fg);
}

.status-indicator[data-status='syncing'] {
  background: var(--status-connecting-bg);
  border-color: var(--status-connecting-border);
  color: var(--status-connecting-fg);
}

.status-indicator[data-status='warn'] {
  background: var(--status-disconnected-bg);
  border-color: var(--status-disconnected-border);
  color: var(--status-disconnected-fg);
}

.status-indicator .material-symbols-outlined {
  font-size: 20px;
  color: currentColor;
}

.delete-indicator {
  border-color: rgba(239, 68, 68, 0.45);
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
}

.delete-indicator:hover {
  background: rgba(239, 68, 68, 0.18);
}

.delete-indicator:focus-visible {
  outline-color: rgba(239, 68, 68, 0.85);
}

.add-indicator {
  border-color: var(--button-ghost-border);
  background: var(--button-ghost-bg);
  color: var(--text-primary);
}

.add-indicator:hover {
  background: var(--button-ghost-hover);
  border-color: var(--button-ghost-border);
}

.add-indicator:focus-visible {
  outline-color: var(--button-ghost-border);
}

.add-floating {
  position: fixed;
  bottom: calc(0.8rem + env(safe-area-inset-bottom));
  width: 60px;
  height: 60px;
  min-width: 60px;
  z-index: 30;
}

.add-floating-left {
  left: calc(0.65rem + env(safe-area-inset-left));
}

.add-floating-right {
  right: calc(0.55rem + env(safe-area-inset-right));
}

.add-floating .material-symbols-outlined {
  font-size: 24px;
}

.presence-indicator {
  height: 40px;
  width: 40px;
  min-width: 40px;
  padding: 0;
  border-radius: 0.85rem;
  border: 1px solid var(--panel-border);
  background: var(--button-ghost-bg);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
}

.presence-indicator .material-symbols-outlined {
  font-size: 18px;
  color: currentColor;
}

.presence-indicator.hidden {
  display: none !important;
}

@media (max-width: 560px) {
  body {
    padding: 0.8rem 0.4rem;
  }

  .title-actions {
    justify-content: flex-start;
  }

  button,
  .icon-button,
  .status-indicator,
  .delete-indicator,
  .add-indicator,
  .presence-indicator {
    width: 36px;
    height: 36px;
    min-width: 36px;
  }

  .add-floating {
    width: 60px;
    height: 60px;
    min-width: 60px;
  }

  .add-floating .material-symbols-outlined {
    font-size: 24px;
  }

  .login-form button {
    width: 100%;
    height: auto;
    min-width: 0;
    min-height: 2.6rem;
  }

  .presence-indicator {
    justify-content: center;
  }

  .copy-feedback {
    transform: translateY(2px) scale(0.9);
  }
}
