:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --panel: #fffdf8;
  --ink: #191713;
  --muted: #6d6860;
  --line: #e5dfd4;
  --shadow: 0 18px 45px rgba(31, 27, 20, 0.12);
  --green: #0f8b8d;
  --coral: #d95d39;
  --violet: #7768ae;
  --danger: #b83f31;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 253, 248, 0.82), rgba(247, 245, 239, 0.96)),
    radial-gradient(circle at 50% -10%, rgba(15, 139, 141, 0.14), transparent 36rem);
  color: var(--ink);
  letter-spacing: 0;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(100%, 520px);
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 18px) clamp(16px, 4vw, 22px) calc(env(safe-area-inset-bottom) + 96px);
}

.topbar {
  position: relative;
  min-height: 62px;
  padding-right: 110px;
  margin-bottom: 20px;
}

.topbar.has-back {
  padding-left: 58px;
}

.topbar-title {
  min-width: 0;
}

.topbar h1 {
  margin: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 33px;
  line-height: 1.04;
  font-weight: 760;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
  text-transform: uppercase;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(25, 23, 19, 0.08);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.72);
  color: var(--ink);
  font-size: 22px;
  line-height: 1;
  box-shadow: 0 8px 20px rgba(31, 27, 20, 0.06);
}

#backBtn {
  position: absolute;
  top: 3px;
  left: 0;
}

.topbar-actions {
  position: absolute;
  top: 3px;
  right: 0;
  display: flex;
  gap: 8px;
}

#refreshBtn {
  color: var(--green);
}

.screen {
  animation: lift 180ms ease-out;
}

@keyframes lift {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin: 22px 2px 12px;
}

.section-heading h2 {
  min-width: 0;
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.area-heading {
  margin-top: 28px;
}

.completed-heading {
  margin-top: 28px;
}

.count-pill {
  min-width: 42px;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(25, 23, 19, 0.06);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.task-list {
  display: grid;
  gap: 10px;
}

.task-card {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  gap: 11px;
  align-items: center;
  min-height: 72px;
  padding: 13px;
  border: 1px solid rgba(25, 23, 19, 0.07);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 9px 24px rgba(31, 27, 20, 0.07);
  transition: transform 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
}

.task-card:active {
  transform: scale(0.99);
}

.task-title {
  margin: 0 0 7px;
  overflow-wrap: anywhere;
  font-size: 17px;
  font-weight: 720;
  line-height: 1.25;
}

.task-main {
  min-width: 0;
}

.area-tag {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--tag-color) 13%, white);
  color: color-mix(in srgb, var(--tag-color) 72%, #191713);
  font-size: 12px;
  font-weight: 740;
}

.check-button, .more-button {
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 20px;
}

.check-button.done {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.more-button {
  border-radius: 14px;
  font-size: 22px;
}

.completed-list .task-card {
  opacity: 0.64;
}

.completed-list .task-title {
  text-decoration: line-through;
}

.area-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.area-button {
  min-height: 96px;
  border: 1px solid rgba(25, 23, 19, 0.07);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,255,255,0.8), rgba(255,253,248,0.96));
  box-shadow: var(--shadow);
  text-align: left;
  padding: 16px;
}

.area-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--area-color);
  margin-bottom: 14px;
}

.area-button strong {
  display: block;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 19px;
  line-height: 1.15;
}

.area-button span {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.area-summary {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  padding: 16px;
  border-radius: 20px;
  background: rgba(255, 253, 248, 0.78);
  border: 1px solid rgba(25, 23, 19, 0.07);
}

.area-summary > div:last-child {
  min-width: 0;
}

.area-summary strong {
  display: block;
  overflow-wrap: anywhere;
}

.area-summary .area-dot {
  margin: 0;
  width: 18px;
  height: 18px;
}

.area-summary p {
  margin: 3px 0 0;
  color: var(--muted);
  font-weight: 650;
}

.fab {
  position: fixed;
  z-index: 10;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  width: min(100% - 36px, 484px);
  height: 60px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 22px;
  background: var(--ink);
  color: #fffdf8;
  box-shadow: 0 20px 46px rgba(25, 23, 19, 0.28);
  font-size: 17px;
  font-weight: 800;
}

.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(25, 23, 19, 0.25);
  padding: 12px;
}

.sheet-panel {
  width: min(100%, 520px);
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px);
  border-radius: 28px 28px 18px 18px;
  background: var(--panel);
  box-shadow: 0 -18px 52px rgba(25, 23, 19, 0.22);
}

.sheet-handle {
  width: 44px;
  height: 5px;
  margin: 2px auto 18px;
  border-radius: 999px;
  background: #d8d0c3;
}

.sheet-panel h2 {
  margin: 0 0 14px;
  font-size: 24px;
}

.stack {
  display: grid;
  gap: 12px;
}

input, select {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  padding: 0 14px;
  font-size: 16px;
}

input:focus, select:focus {
  outline: 3px solid rgba(15, 139, 141, 0.18);
  border-color: var(--green);
}

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-items: center;
  margin-top: 6px;
}

.sheet-actions .danger-button:not(.hidden) {
  grid-column: 1 / -1;
}

.primary-button, .secondary-button, .danger-button, .small-button, .text-button {
  min-height: 48px;
  border-radius: 16px;
  border: 1px solid transparent;
  padding: 0 14px;
  font-weight: 780;
}

.primary-button, .small-button {
  background: var(--green);
  color: #fff;
}

.secondary-button {
  background: rgba(25, 23, 19, 0.06);
  color: var(--ink);
}

.danger-button {
  background: rgba(184, 63, 49, 0.1);
  color: var(--danger);
}

.text-button {
  min-height: 40px;
  background: transparent;
  color: var(--green);
}

.inline-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 54px 76px;
  gap: 10px;
  margin-bottom: 16px;
}

.inline-form input[type="color"] {
  padding: 4px;
}

.manage-list {
  display: grid;
  gap: 10px;
}

.area-row {
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) 42px 42px 42px;
  gap: 8px;
  align-items: center;
  min-height: 62px;
  padding: 10px;
  border: 1px solid rgba(25, 23, 19, 0.07);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.88);
}

.area-row strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.area-row .area-dot {
  margin: 0;
}

.row-icon {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--muted);
  font-weight: 800;
}

.settings-block {
  padding: 18px;
  border: 1px solid rgba(25, 23, 19, 0.07);
  border-radius: 20px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.settings-block h2 {
  margin: 0;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.settings-block p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.4;
}

.ready-note {
  color: var(--green) !important;
  font-weight: 760;
}

.settings-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(217, 93, 57, 0.12);
  color: var(--coral);
  font-size: 12px;
  font-weight: 820;
}

.endpoint-box {
  display: grid;
  gap: 8px;
  margin: 14px 0 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
}

.endpoint-box span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.endpoint-box code {
  overflow-wrap: anywhere;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.35;
}

.integration-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.integration-result {
  min-height: 20px;
  margin: 12px 0 0 !important;
  font-weight: 720;
}

.empty {
  min-height: 70px;
  display: grid;
  place-items: center;
  border: 1px dashed #d8d0c3;
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  padding: 16px;
  font-weight: 650;
}

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 88px);
  transform: translateX(-50%);
  max-width: min(420px, calc(100% - 32px));
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--ink);
  color: #fff;
  font-weight: 720;
  box-shadow: 0 16px 36px rgba(25, 23, 19, 0.24);
}

.hidden {
  display: none !important;
}

@media (min-width: 720px) {
  body {
    background:
      linear-gradient(180deg, rgba(255, 253, 248, 0.82), rgba(247, 245, 239, 0.96)),
      radial-gradient(circle at 50% 0%, rgba(217, 93, 57, 0.12), transparent 34rem);
  }

  .app-shell {
    padding-top: 36px;
  }
}

@media (max-width: 370px) {
  .area-grid {
    grid-template-columns: 1fr;
  }

  .inline-form {
    grid-template-columns: 1fr 54px;
  }

  .inline-form .small-button {
    grid-column: 1 / -1;
  }
}
