:root {
  --bg: #f5f3ee;
  --panel: #fffdf8;
  --ink: #20201e;
  --muted: #6f6b62;
  --line: #ddd7cb;
  --accent: #287a76;
  --accent-dark: #1c5754;
  --low: #5f8f4f;
  --medium: #b77b1d;
  --high: #c8553d;
  --urgent: #8e2f4f;
  --shadow: 0 18px 45px rgba(42, 35, 24, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  box-shadow: var(--shadow);
  z-index: 2;
  overflow-y: auto;
}

.brand-row,
.section-heading,
.button-row,
.toolbar,
.filters {
  display: flex;
  align-items: center;
}

.brand-row {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.1;
}

h1 {
  font-size: 1.65rem;
}

h2 {
  font-size: 1rem;
}

.icon-button,
.toolbar button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
}

.task-form {
  display: grid;
  gap: 14px;
}

.form-mode {
  margin: 0;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 850;
}

.hidden {
  display: none;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 750;
}

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

textarea {
  min-height: 84px;
  resize: vertical;
  padding: 11px 12px;
}

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

textarea:focus,
input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(40, 122, 118, 0.16);
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.button-row {
  gap: 10px;
}

.primary-button,
.secondary-button,
.text-button,
.filter {
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 0 14px;
}

.primary-button {
  flex: 1;
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button,
.filter,
.text-button {
  background: #ffffff;
  color: var(--ink);
  border-color: var(--line);
}

.toolbar {
  justify-content: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7ef;
}

#zoomLevel {
  min-width: 58px;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 850;
}

.task-list-section {
  display: grid;
  gap: 12px;
  min-height: 0;
}

.save-status {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.section-heading {
  justify-content: space-between;
  gap: 12px;
}

.text-button {
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

.filters {
  gap: 8px;
}

.filter {
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.8rem;
}

.filter.active {
  background: #20201e;
  border-color: #20201e;
  color: #ffffff;
}

.task-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 5px solid var(--priority-color);
  border-radius: 8px;
  background: #ffffff;
}

.task-card.done {
  opacity: 0.58;
}

.task-card strong {
  overflow-wrap: anywhere;
  font-size: 0.94rem;
}

.task-meta,
.task-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.task-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.task-actions button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7ef;
  min-height: 36px;
  padding: 6px 9px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 850;
}

.map-area {
  position: relative;
  min-width: 0;
  background:
    radial-gradient(circle at 25% 20%, rgba(40, 122, 118, 0.12), transparent 28%),
    linear-gradient(145deg, #ede9df 0%, #f9f6ee 42%, #e8eef0 100%);
}

#taskCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.map-help {
  position: absolute;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  max-width: min(560px, calc(100% - 36px));
  pointer-events: none;
}

.map-help span {
  padding: 7px 10px;
  border: 1px solid rgba(32, 32, 30, 0.12);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.78);
  color: #4b4943;
  font-size: 0.78rem;
  font-weight: 800;
  backdrop-filter: blur(8px);
}

@media (max-width: 840px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(520px, 64svh);
    height: auto;
    min-height: 100vh;
    min-height: 100svh;
    overflow: visible;
  }

  .sidebar {
    gap: 16px;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    box-shadow: none;
  }

  .map-area {
    min-height: 520px;
  }

  .task-list {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  }
}

@media (max-width: 460px) {
  .sidebar {
    padding: 16px;
  }

  .brand-row {
    align-items: flex-start;
  }

  h1 {
    font-size: 1.38rem;
  }

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

  .button-row {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .toolbar {
    justify-content: space-between;
  }

  .toolbar button,
  .icon-button {
    width: 44px;
    height: 44px;
  }

  .filters {
    flex-wrap: wrap;
  }

  .filter {
    flex: 1 1 72px;
    min-height: 38px;
  }

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

  .task-meta,
  .task-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .task-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .task-actions button {
    padding-inline: 6px;
  }

  .map-area {
    min-height: 460px;
  }

  .map-help {
    right: 10px;
    bottom: 10px;
    left: 10px;
    justify-content: flex-start;
    max-width: none;
  }

  .map-help span {
    font-size: 0.7rem;
    padding: 6px 8px;
  }
}
