:root {
  --app-font-size: 14px;
  --font-sans: "Pretendard", "Malgun Gothic", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

  /* Default: Post-it warm theme */
  --outer-bg: #efe7c6;
  --bg: #fdf8e1;
  --surface: #f7ecc0;
  --surface-hover: #f2e2a5;
  --card-bg: #fffdf2;
  --border: #e4d498;
  --guide: #d9b65c;
  --text: #2b2518;
  --text-muted: #786a4b;
  --text-completed: #9a8d6e;
  --accent: #b45309;
  --accent-bg: rgba(180, 83, 9, 0.12);
  --accent-text: #ffffff;
  --danger: #c62828;
  --danger-bg: rgba(198, 40, 40, 0.1);
  --warning: #d97706;
  --warning-bg: rgba(217, 119, 6, 0.12);
  --warning-border: rgba(217, 119, 6, 0.3);
  --sync-ok: #4d7c5b;
  --sync-ok-dot: #4ea36a;
  --sync-local: #3e6b8e;
  --sync-local-dot: #4a89bd;
  --sync-err: #b8504b;
  --sync-err-dot: #d65b55;
  --sync-pending: #9a6d33;
  --shadow: 0 8px 28px rgba(74, 56, 15, 0.12);
  --focus-ring: rgba(180, 83, 9, 0.28);
}

html[data-theme="light"] {
  --outer-bg: #eef0f4;
  --bg: #ffffff;
  --surface: #f6f7f9;
  --surface-hover: #eceff4;
  --card-bg: #ffffff;
  --border: #e2e6ed;
  --guide: #cbd5e1;
  --text: #181c24;
  --text-muted: #64748b;
  --text-completed: #94a3b8;
  --accent: #2563eb;
  --accent-bg: rgba(37, 99, 235, 0.1);
  --accent-text: #ffffff;
  --danger: #dc2626;
  --danger-bg: rgba(220, 38, 38, 0.1);
  --warning: #ea580c;
  --warning-bg: rgba(234, 88, 12, 0.1);
  --warning-border: rgba(234, 88, 12, 0.28);
  --sync-ok: #477857;
  --sync-ok-dot: #4ea36a;
  --sync-local: #35668f;
  --sync-local-dot: #4a89bd;
  --sync-err: #b94a48;
  --sync-err-dot: #d65b55;
  --sync-pending: #9e6b2e;
  --shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
  --focus-ring: rgba(37, 99, 235, 0.24);
}

html[data-theme="dark"] {
  --outer-bg: #111215;
  --bg: #1b1d22;
  --surface: #23262e;
  --surface-hover: #2c303a;
  --card-bg: #20232a;
  --border: #333744;
  --guide: #4b5263;
  --text: #edf0f5;
  --text-muted: #9aa3b2;
  --text-completed: #6e7685;
  --accent: #f59e0b;
  --accent-bg: rgba(245, 158, 11, 0.16);
  --accent-text: #18191d;
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.15);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.14);
  --warning-border: rgba(245, 158, 11, 0.32);
  --sync-ok: #7fc196;
  --sync-ok-dot: #5ab87c;
  --sync-local: #7db4e0;
  --sync-local-dot: #62a3d9;
  --sync-err: #e08282;
  --sync-err-dot: #e06c6c;
  --sync-pending: #d9b066;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  --focus-ring: rgba(245, 158, 11, 0.3);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--outer-bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

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

button {
  cursor: pointer;
}

/* ==================== Auth View ==================== */
.auth-view {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
}

.auth-card {
  width: 100%;
  max-width: 340px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 16px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.auth-icon {
  flex-shrink: 0;
}

.auth-title {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  background: var(--surface);
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 8px 6px;
  min-height: 36px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  transition: background 0.15s, color 0.15s;
}

.auth-tab.active {
  background: var(--card-bg);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.field input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  outline: none;
  font-size: 14px;
}

.field input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-error {
  margin: 0;
  font-size: 12px;
  color: var(--danger);
  background: var(--danger-bg);
  padding: 7px 9px;
  border-radius: 6px;
}

.auth-hint {
  margin: 10px 0 0;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px 0 10px;
  font-size: 11px;
  color: var(--text-muted);
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.app-copyright {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.68;
  text-align: center;
  letter-spacing: -0.01em;
  user-select: none;
}

.auth-copyright {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.settings-copyright {
  padding-top: 4px;
}

/* ==================== Buttons ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}

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

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 34px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-xs {
  min-height: 26px;
  padding: 0 9px;
  font-size: 11.5px;
  border-radius: 6px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
}

.btn-warning {
  background: var(--warning);
  color: #ffffff;
}

.btn-warning:hover:not(:disabled) {
  filter: brightness(1.06);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger:hover:not(:disabled) {
  filter: brightness(1.06);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn.compact {
  min-width: 32px;
  min-height: 32px;
  font-size: 12px;
  font-weight: 700;
}

/* ==================== App Shell ==================== */
.app-shell {
  width: 100%;
  max-width: 540px;
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
  min-width: 260px;
}

@media (max-width: 540px) {
  .app-shell {
    max-width: 100%;
    border-left: none;
    border-right: none;
    box-shadow: none;
  }
}

/* ==================== Topbar ==================== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 4px 0 7px;
  min-height: 23px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  user-select: none;
  position: relative;
  z-index: 20;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.app-mark {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.app-mark img {
  width: 13px;
  height: 13px;
}

.topbar .icon-btn {
  min-width: 22px;
  min-height: 22px;
  width: 22px;
  height: 22px;
}

.topbar .icon-btn svg {
  width: 13px;
  height: 13px;
}

.brand-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  padding: 0 3px;
  border-radius: 4px;
  cursor: help;
  outline: none;
  transition: color 0.2s ease, background 0.15s ease;
}

.brand-status:hover,
.brand-status:focus-visible {
  background: var(--surface-hover);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  flex-shrink: 0;
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.brand-status.is-synced {
  color: var(--sync-ok);
}

.brand-status.is-synced .status-dot {
  background: var(--sync-ok-dot);
  box-shadow: 0 0 0 2px rgba(78, 163, 106, 0.18);
}

.brand-status.is-local {
  color: var(--sync-local);
}

.brand-status.is-local .status-dot {
  background: var(--sync-local-dot);
  box-shadow: 0 0 0 2px rgba(74, 137, 189, 0.2);
}

.brand-status.is-unsynced {
  color: var(--sync-err);
}

.brand-status.is-unsynced .status-dot {
  background: var(--sync-err-dot);
  box-shadow: 0 0 0 2px rgba(214, 91, 85, 0.2);
}

.brand-status.is-saving {
  color: var(--sync-pending);
}

.brand-status.is-saving .status-dot {
  background: var(--sync-pending);
  animation: syncPulse 1s ease-in-out infinite;
}

@keyframes syncPulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

.brand-name-wrap {
  display: inline-flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 1px 4px;
  min-width: 0;
  line-height: 1.2;
}

.brand-name {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: -0.02em;
  word-break: keep-all;
}

.brand-sub {
  font-size: 9.5px;
  font-weight: 500;
  opacity: 0.78;
}

.brand-version {
  font-size: 9px;
  font-weight: 600;
  padding: 0 3px;
  border-radius: 3px;
  border: 1px solid currentColor;
  opacity: 0.65;
  line-height: 1.2;
  flex-shrink: 0;
}

@media (max-width: 340px) {
  .brand-name {
    font-size: 10px;
  }
  .brand-sub {
    font-size: 9px;
  }
  .brand-version {
    font-size: 8.5px;
  }
}

.sync-tooltip {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 40;
  width: max-content;
  max-width: min(250px, calc(100vw - 24px));
  padding: 8px 10px;
  border-radius: 8px;
  background: #1f242d;
  color: #f8fafc;
  font-size: 11.5px;
  line-height: 1.45;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.3);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
}

.brand-status:hover .sync-tooltip,
.brand-status:focus-visible .sync-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.sync-tooltip-current {
  font-weight: 700;
  padding-bottom: 5px;
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.sync-tooltip-legend {
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 11px;
  color: #cbd5e1;
}

.legend-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 999px;
  margin-right: 5px;
  vertical-align: middle;
}

.legend-dot.synced {
  background: #22c55e;
}

.legend-dot.local {
  background: #4a89bd;
}

.legend-dot.unsynced {
  background: #ef4444;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.font-controls {
  display: inline-flex;
  align-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0 2px;
}

.font-size-label {
  min-width: 34px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Font default save banner */
.font-save-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 5px 10px;
  background: var(--accent-bg);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  flex-shrink: 0;
}

.font-save-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.btn-chip {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11.5px;
  font-weight: 600;
  min-height: 26px;
}

.btn-chip-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* ==================== Composer ==================== */
.composer {
  display: flex;
  align-items: flex-start;
  gap: 4px;
  padding: 8px 6px 8px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  flex-shrink: 0;
}

.composer-input {
  flex: 1;
  min-width: 0;
  min-height: 36px;
  max-height: 110px;
  padding: 7px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  font-size: var(--app-font-size);
  line-height: 1.4;
  resize: none;
  outline: none;
  overflow-y: auto;
}

.composer-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.composer-input::placeholder {
  color: var(--text-muted);
  opacity: 0.75;
}

.composer-submit {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 8px;
}

.composer-submit:hover {
  background: var(--accent);
  color: var(--accent-text);
  filter: brightness(1.06);
}

/* ==================== Workspace Scroll & Lists ==================== */
.workspace-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 6px 4px 28px;
}

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.task-item {
  border-bottom: 1px dashed var(--border);
  padding: 3px 2px 5px;
}

.task-item:last-child {
  border-bottom: none;
}

.task-item.duplicate-flash > .task-row {
  animation: duplicateBlink 0.72s ease-in-out 3;
  border-radius: 8px;
}

@keyframes duplicateBlink {
  0%,
  100% {
    background: transparent;
    box-shadow: inset 0 0 0 0 transparent;
  }
  40%,
  60% {
    background: rgba(245, 158, 11, 0.34);
    box-shadow: inset 0 0 0 2px var(--accent);
  }
}

.dup-badge {
  align-self: center;
  flex-shrink: 0;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.02em;
  animation: duplicateBadgePulse 0.72s ease-in-out 3;
}

@keyframes duplicateBadgePulse {
  0%,
  100% {
    opacity: 0.7;
    transform: scale(0.96);
  }
  50% {
    opacity: 1;
    transform: scale(1.06);
  }
}

.task-row {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  min-height: 36px;
  border-radius: 7px;
  transition: background 0.12s;
}

.task-row:hover,
.task-row:focus-within {
  background: rgba(128, 128, 128, 0.06);
}

.task-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-muted);
  opacity: 0.45;
  flex-shrink: 0;
  border-radius: 5px;
  cursor: grab;
  touch-action: none;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
}

.task-row:hover .task-drag-handle,
.task-drag-handle:hover {
  opacity: 1;
  color: var(--accent);
  background: var(--accent-bg);
}

.task-item.dragging-float {
  background: var(--card-bg);
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
  opacity: 0.96;
  padding: 3px 2px 5px;
}

.task-drop-placeholder {
  list-style: none;
  margin: 3px 0;
  border-radius: 8px;
  background: var(--accent-bg);
  border: 1.5px dashed var(--accent);
}

/* Touch-friendly checkbox wrapper */
.check-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  flex-shrink: 0;
  border-radius: 7px;
}

.check-btn:hover {
  background: var(--surface-hover);
}

.check-box {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  border: 2px solid var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  transition: background 0.15s, border-color 0.15s;
}

.check-btn.checked .check-box {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.item-body {
  flex: 1;
  min-width: 0;
  padding: 6px 2px 4px;
}

.inline-editor {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  padding: 1px 3px;
  margin: 0;
  resize: none;
  overflow: hidden;
  outline: none;
  font-size: var(--app-font-size);
  line-height: 1.45;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  border-radius: 4px;
}

.inline-editor:focus {
  background: var(--card-bg);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.task-item.completed .task-editor {
  text-decoration: line-through;
  color: var(--text-completed);
}

.item-actions {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 28px;
  min-height: 36px;
  padding: 0 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  border-radius: 6px;
}

.collapse-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.collapse-chevron {
  display: inline-block;
  transition: transform 0.15s ease;
  font-size: 10px;
}

.task-item.collapsed .collapse-chevron {
  transform: rotate(-90deg);
}

.insert-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  flex-shrink: 0;
  border-radius: 7px;
}

.insert-btn-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 24px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--accent);
  line-height: 1;
  transition: background 0.12s, border-color 0.12s, color 0.12s, transform 0.1s;
}

.insert-btn:hover .insert-btn-pill {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--accent);
}

.insert-btn:active .insert-btn-pill {
  transform: scale(0.96);
}

.insert-btn.is-limit .insert-btn-pill {
  opacity: 0.4;
}

.delete-btn {
  min-width: 28px;
  min-height: 36px;
  font-size: 16px;
  color: var(--text-muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s, color 0.12s, background 0.12s;
}

.task-row:hover .delete-btn,
.task-row:focus-within .delete-btn,
.subtask-row:hover .delete-btn,
.subtask-row:focus-within .delete-btn {
  opacity: 1;
  pointer-events: auto;
}

.delete-btn:hover {
  color: var(--danger);
  background: var(--danger-bg);
}

/* On narrow screens (< 340px), keep delete hidden unless focused so text stays wide */
@media (max-width: 340px) {
  .delete-btn {
    display: none;
  }
  .task-row:focus-within .delete-btn,
  .subtask-row:focus-within .delete-btn {
    display: inline-flex;
    opacity: 1;
    pointer-events: auto;
  }
}

/* ==================== Subtasks (History) ==================== */
.subtask-list {
  list-style: none;
  margin: 1px 0 2px 16px;
  padding: 0 0 0 6px;
  border-left: 2px solid var(--guide);
}

.task-item.collapsed .subtask-list {
  display: none;
}

.subtask-row {
  display: flex;
  align-items: flex-start;
  gap: 2px;
  min-height: 36px;
  border-radius: 6px;
  transition: background 0.12s;
}

.subtask-row:hover,
.subtask-row:focus-within {
  background: rgba(128, 128, 128, 0.06);
}

.subtask-check-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 36px;
  padding: 0;
  border: none;
  background: transparent;
  flex-shrink: 0;
  border-radius: 6px;
}

.subtask-check-btn:hover {
  background: var(--surface-hover);
}

.subtask-check-box {
  width: 15px;
  height: 15px;
  border-radius: 4px;
  border: 1.8px solid var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card-bg);
  transition: background 0.15s, border-color 0.15s;
}

.subtask-check-btn.checked .subtask-check-box {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.subtask-body {
  flex: 1;
  min-width: 0;
  padding: 6px 2px 4px;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 6px;
}

.subtask-editor {
  flex: 1 1 110px;
  font-size: calc(var(--app-font-size) * 0.92);
  color: var(--text);
}

.subtask-item.completed .subtask-editor {
  text-decoration: line-through;
  color: var(--text-completed);
}

.task-item.completed .subtask-editor {
  color: var(--text-completed);
}

.subtask-time {
  font-size: 10.5px;
  color: var(--text-muted);
  opacity: 0.72;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  user-select: none;
  padding: 2px 5px;
  border-radius: 4px;
  cursor: grab;
  touch-action: none;
  transition: background 0.12s, color 0.12s, opacity 0.12s;
}

.subtask-time:hover {
  opacity: 1;
  color: var(--accent);
  background: var(--accent-bg);
}

.subtask-time:active,
body.is-reordering,
body.is-reordering * {
  cursor: grabbing !important;
  user-select: none !important;
}

.subtask-item.dragging-float > .subtask-row {
  background: var(--card-bg);
  border-radius: 7px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18), 0 0 0 1.5px var(--accent);
  opacity: 0.96;
}

.subtask-drop-placeholder {
  list-style: none;
  margin: 2px 0;
  border-radius: 6px;
  background: var(--accent-bg);
  border: 1.5px dashed var(--accent);
}

@media (max-width: 360px) {
  .subtask-body {
    flex-direction: column;
    gap: 1px;
  }
  .subtask-editor {
    flex: none;
    width: 100%;
  }
  .subtask-time {
    font-size: 10px;
    opacity: 0.65;
  }
}

/* ==================== Completed Section ==================== */
.completed-section {
  margin-top: 14px;
}

.section-divider {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  user-select: none;
}

.section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.completed-list {
  opacity: 0.85;
}

/* ==================== Empty State ==================== */
.empty-state {
  padding: 36px 18px;
  text-align: center;
  color: var(--text-muted);
}

.empty-title {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.empty-desc {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
}

/* ==================== Modals ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
}

.modal-panel {
  width: 100%;
  max-width: 340px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.modal-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.modal-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

.modal-stack-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-group {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-group:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.setting-label {
  font-size: 13px;
  font-weight: 700;
}

.setting-sub {
  margin: 0;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.setting-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.remote-server-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.remote-server-input {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--card-bg);
  font-size: 12px;
  outline: none;
}

.remote-server-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.storage-picker {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.storage-option {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.storage-option.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}

.theme-picker {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.theme-option {
  min-height: 34px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--surface);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.theme-option.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--accent);
}

.warning-zone {
  background: var(--warning-bg);
  padding: 10px !important;
  border-radius: 8px;
  border: 1px solid var(--warning-border) !important;
}

.warning-text {
  color: var(--warning);
}

.danger-zone {
  background: var(--danger-bg);
  padding: 10px !important;
  border-radius: 8px;
  border: 1px solid rgba(198, 40, 40, 0.25) !important;
}

.danger-zone-compact {
  display: grid !important;
  grid-template-columns: 4fr 1fr;
  align-items: center;
  gap: 8px;
  padding: 7px 9px !important;
}

.danger-compact-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.danger-compact-action {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.danger-compact-action .btn-xs {
  padding: 5px 4px;
  font-size: 11px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  white-space: normal;
  text-align: center;
}

.danger-zone-compact .setting-label {
  font-size: 12px;
}

.danger-zone-compact .setting-sub {
  font-size: 10.5px;
  line-height: 1.32;
}

.danger-text {
  color: var(--danger);
}

.reset-warning {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}

/* ==================== Toast ==================== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  z-index: 60;
  max-width: calc(100vw - 24px);
  padding: 8px 14px;
  border-radius: 8px;
  background: #1f242d;
  color: #f8fafc;
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.28);
  text-align: center;
}

/* ==================== Floating Settings Help Tooltip ==================== */
.floating-help-tooltip {
  position: fixed;
  z-index: 200;
  max-width: min(268px, calc(100vw - 20px));
  padding: 8px 10px;
  border-radius: 8px;
  background: #1f242d;
  color: #f8fafc;
  font-size: 11px;
  line-height: 1.45;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.36);
  pointer-events: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.floating-help-title {
  font-size: 11.5px;
  font-weight: 700;
  color: #f8fafc;
  padding-bottom: 4px;
  margin-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.14);
}

.floating-help-list {
  margin: 0;
  padding-left: 13px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: #cbd5e1;
}

.floating-help-list li {
  word-break: keep-all;
}
