:root {
  --bg: #f6f9ff;
  --surface: #ffffff;
  --surface-soft: #eef4ff;
  --text: #0a0a0a;
  --muted: #4f5d75;
  --blue: #0f62fe;
  --blue-soft: #d9e7ff;
  --border: #d8e1f1;
  --danger: #d72638;
  --warning: #f2c94c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  color: var(--text);
  background: linear-gradient(150deg, var(--bg), #eaf1ff 55%, #ffffff);
}

.app {
  width: min(960px, 94vw);
  margin: 2rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 1.4rem;
  box-shadow: 0 24px 60px rgba(15, 98, 254, 0.1);
}

.app-header h1 {
  margin: 0;
  font-size: 1.8rem;
}

.app-header p {
  margin: 0.35rem 0 0;
  color: var(--muted);
}

.header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.language-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-width: 200px;
}

.sync-panel {
  margin-top: 1rem;
  border: 1px solid var(--border);
  background: #f8fbff;
  border-radius: 14px;
  padding: 0.8rem;
}

.sync-panel.is-local-clean {
  background: #fbfdff;
  border-style: dashed;
  padding: 0.55rem 0.7rem;
}

.sync-top {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.sync-panel.is-local-clean .sync-top {
  gap: 0.5rem;
}

.is-hidden {
  display: none !important;
}

#sync-status {
  background: var(--blue-soft);
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
}

.sync-panel.is-local-clean #sync-status {
  background: #eef3ff;
  border: 1px solid #d7e4ff;
  font-weight: 600;
}

.cloud-panel-body {
  margin-top: 0.6rem;
}

.cloud-panel-body.is-collapsed {
  display: none;
}

.sync-panel-body.is-collapsed {
  display: none;
}

.sync-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.sync-grid:last-child {
  grid-template-columns: 1fr auto;
}

input,
select,
button {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.55rem 0.8rem;
  font-size: 0.92rem;
}

input {
  width: 100%;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(15, 98, 254, 0.16);
}

button {
  cursor: pointer;
}

#sync-now-btn,
#toggle-cloud-btn,
#toggle-sync-panel-btn,
#save-cloud-btn,
#email-login-btn,
#notify-btn,
#archive-btn {
  background: var(--surface-soft);
}

#sync-now-btn:hover,
#toggle-cloud-btn:hover,
#toggle-sync-panel-btn:hover,
#save-cloud-btn:hover,
#email-login-btn:hover,
#notify-btn:hover,
#archive-btn:hover {
  border-color: var(--blue);
}

.sync-panel.is-local-clean #toggle-sync-panel-btn {
  background: #fff;
}

.controls {
  margin-top: 1rem;
}

.create-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.6rem;
  align-items: center;
}

#task-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#task-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(15, 98, 254, 0.16);
}

#add-task-btn {
  min-width: 96px;
  align-self: stretch;
  background: var(--blue);
  color: #fff;
  border-color: var(--blue);
}

#add-task-btn:hover {
  filter: brightness(0.95);
}

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

.toolbar {
  margin-top: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.filters-row {
  margin-top: 0.65rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.filter-btn {
  background: #fff;
}

.filter-btn.is-active {
  background: var(--blue-soft);
  border-color: #b8ccf5;
  font-weight: 600;
}

.tasks-summary {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.88rem;
}

label {
  font-size: 0.9rem;
  color: var(--muted);
}

.list-section {
  margin-top: 1.2rem;
  max-height: 54vh;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fbfdff;
}

#task-list,
#archived-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.empty-list-item {
  padding: 1rem 0.9rem;
  color: var(--muted);
}

.task-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  gap: 0.8rem;
  align-items: center;
  padding: 0.78rem 0.9rem;
  border-bottom: 1px solid var(--border);
}

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

.toggle {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 2px solid var(--blue);
  background: #fff;
  padding: 0;
}

.task-item.completed .toggle {
  background: var(--blue);
}

.task-item.completed .task-text {
  text-decoration: line-through;
  color: #6a7890;
}

.task-main {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.task-text {
  display: inline-block;
  min-width: 0;
  outline: none;
  border-radius: 6px;
  padding: 0.1rem 0.2rem;
}

.task-text[contenteditable="true"] {
  border: 1px solid var(--blue);
  background: #fff;
}

.priority-dots {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
}

.dot-none {
  background: #dce5f4;
}

.dot-yellow {
  background: var(--warning);
}

.dot-red {
  background: var(--danger);
}

.dot.active {
  border-color: #0a0a0a;
  transform: scale(1.08);
}

.task-date {
  color: var(--muted);
  white-space: nowrap;
}

.delete {
  border-color: #e7b2b8;
  background: #fff;
  color: #b00020;
}

.archive-section {
  margin-top: 1.2rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem;
  background: #f9fbff;
}

.archive-section h2 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
}

#archived-list li {
  padding: 0.5rem 0.4rem;
  border-bottom: 1px solid var(--border);
  color: #556178;
}

#archived-list li:last-child {
  border-bottom: 0;
}

@media (max-width: 800px) {
  .header-row {
    flex-direction: column;
    align-items: stretch;
  }

  .language-box {
    min-width: 0;
  }

  .sync-grid,
  .sync-grid:last-child {
    grid-template-columns: 1fr;
  }

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

  #add-task-btn {
    width: 100%;
  }

  .tasks-summary {
    width: 100%;
    margin-left: 0;
  }

  .task-item {
    grid-template-columns: auto 1fr auto;
  }

  .task-date {
    grid-column: 2 / -1;
    margin-top: -0.3rem;
  }
}
