:root {
  --panel: #ffffff;
  --ink: #1f2933;
  --muted: #6f7d8a;
  --line: #d7dee6;
  --overflow: #d97070;
  --accent: #2b6cb0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f6f8fb 0%, #eef2f7 100%);
}

.app-shell {
  height: 100vh;
  padding: 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: 10px;
}

.top-bar {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 16px;
  padding: 10px 14px;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.top-meta {
  width: 100%;
}

.month-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.top-bar h1 {
  margin: 0;
  font-size: clamp(1rem, 2.8vw, 1.3rem);
  font-weight: 700;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.bottom-bar {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  padding: 8px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
}

.bottom-add-btn {
  width: 100%;
  border-color: #2b6cb0;
  background: #2b6cb0;
  color: #fff;
  font-weight: 700;
}

.jump-today-link {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 0.74rem;
  color: #2b6cb0;
  text-decoration: underline;
  text-underline-offset: 2px;
  width: fit-content;
  margin-left: auto;
}

.recurrence-icon {
  color: #7a8794;
  font-size: 0.78em;
}

button,
input,
select {
  font-family: inherit;
}

button,
select,
input {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 8px 10px;
}

button {
  cursor: pointer;
}

button.secondary {
  background: #f5f8fb;
}

.primary-btn {
  border-color: #2b6cb0;
  background: #2b6cb0;
  color: #fff;
}

.archive-btn {
  border-color: #dc3f3f;
  background: #fff5f5;
  color: #b42323;
}

.days-stage,
.categories-panel {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  overflow: hidden;
  min-height: 0;
}

.day-strip {
  height: 100%;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 12px;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  scrollbar-gutter: stable;
}

.day-strip::-webkit-scrollbar,
.category-list::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

.day-strip::-webkit-scrollbar-thumb,
.category-list::-webkit-scrollbar-thumb {
  background: #c8d2dd;
  border-radius: 999px;
}

.day-card {
  flex: 0 0 min(220px, 70vw);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfdff;
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  min-width: 0;
  scroll-snap-align: start;
}

.day-card.is-weekend-soft {
  background: #f5f6f8;
}

.day-card.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent) inset;
}

.day-card.is-overflow {
  border-color: var(--overflow);
  box-shadow: 0 0 0 1px color-mix(in oklab, var(--overflow) 40%, white) inset;
}

.day-head {
  display: flex;
  justify-content: space-between;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 0.9rem;
  font-weight: 600;
}

.day-total {
  color: var(--muted);
}

.allocations {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  overflow: hidden;
}

.task-block {
  border-radius: 10px;
  border: 1px solid color-mix(in oklab, var(--card-color) 55%, #ffffff);
  background: color-mix(in oklab, var(--card-color) 22%, #ffffff);
  color: var(--ink);
}

.allocation {
  display: grid;
  grid-template-rows: 1fr auto;
  min-height: 0;
}

.allocation-main {
  padding: 7px 8px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  min-height: 0;
}

.allocation-text {
  min-width: 0;
  flex: 1;
}

.allocation-title {
  font-size: 0.85rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.allocation-meta {
  font-size: 0.75rem;
  color: #223;
  opacity: 0.85;
}

.allocation-controls {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.drag-handle {
  border: 0;
  background: transparent;
  color: #4a5968;
  cursor: grab;
  padding: 0 4px;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1;
  touch-action: none;
}

.drag-handle:active {
  cursor: grabbing;
}

.resize-control {
  border: 0;
  background: transparent;
  color: #4a5968;
  cursor: ns-resize;
  padding: 0 3px;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1;
  touch-action: none;
}

.category-list {
  height: 100%;
  overflow-y: auto;
  scrollbar-width: thin;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 8px;
  align-content: start;
  scrollbar-gutter: stable;
}

.category {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  background: #fcfdff;
  min-height: 72px;
}

.category-name {
  font-size: 0.8rem;
  font-weight: 700;
  margin-bottom: 6px;
  line-height: 1.1;
}

.templates {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.template {
  width: 100%;
  min-height: 28px;
  padding: 4px 6px;
  font-size: 0.75rem;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.template-label {
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.template .drag-handle {
  margin-left: auto;
}

.task-block.is-drag-origin {
  opacity: 0.45;
}

.drag-preview {
  position: fixed;
  top: 0;
  left: 0;
  width: min(220px, 56vw);
  padding: 8px 10px;
  z-index: 2200;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
  transform: rotate(1.3deg);
}

.day-card.is-drop-target {
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 55%, #fff) inset;
}

.day-card.is-drop-target-disabled {
  border-color: #c4ccd5;
  box-shadow: 0 0 0 2px #d5dbe2 inset;
}

.category-list.is-remove-target {
  box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--overflow) 60%, #fff);
}

body.is-dragging {
  user-select: none;
}

.edit-dropzone {
  width: 100%;
  border: 1px dashed var(--accent);
  background: color-mix(in oklab, var(--accent) 10%, #ffffff);
  border-radius: 10px;
  padding: 9px 12px;
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #214d76;
}

.edit-dropzone.is-edit-target {
  background: color-mix(in oklab, var(--accent) 22%, #ffffff);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--accent) 30%, #fff);
}

.task-modal {
  width: min(420px, calc(100vw - 24px));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0;
}

.task-modal::backdrop {
  background: rgba(29, 40, 54, 0.35);
}

.modal-shell {
  padding: 16px;
  display: grid;
  gap: 14px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h2 {
  margin: 0;
}

.close-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0;
}

.modal-section {
  display: grid;
  gap: 8px;
}

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

.recurrence-toggle {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  padding: 0;
  line-height: 1;
  color: #6a7785;
}

.recurrence-toggle.is-active {
  border-color: #2b6cb0;
  color: #2b6cb0;
  background: color-mix(in oklab, #2b6cb0 10%, #fff);
}

.recurrence-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  font-size: 0.78rem;
  color: #3b4753;
}

.recurrence-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.modal-section > label {
  font-size: 0.92rem;
  font-weight: 700;
  text-align: left;
}

.modal-section input,
.modal-section select {
  width: 100%;
}

.new-category-row {
  display: grid;
  gap: 6px;
  grid-template-columns: minmax(0, 1fr) auto auto;
}

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

.is-hidden {
  display: none;
}

@media (max-width: 860px) {
  .day-card {
    flex-basis: min(200px, 78vw);
  }

  .category-list {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  }

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