@import url("https://fonts.googleapis.com/css2?family=DM+Serif+Display&family=Lora:wght@400;500;600;700&display=swap");

:root {
  color-scheme: light;
  --bg: #fffaf0;
  --panel: #fffefb;
  --ink: #4c2f27;
  --muted: #7b6259;
  --line: #eadcae;
  --brand: #8aa37a;
  --brand-strong: #6e895f;
  --accent: #fff1b5;
  --blue: #a9d2e5;
  --terracotta: #bd5631;
  --danger: #b42318;
  --shadow: 0 18px 42px rgba(76, 47, 39, 0.1);
  --heading: "DM Serif Display", Georgia, serif;
  --body: "Lora", Georgia, serif;
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100%;
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 241, 181, 0.82), rgba(255, 250, 240, 0) 310px),
    var(--bg);
}

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

.app-shell {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(30px, env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 2px 20px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--brand-strong);
  font-family: var(--heading);
  font-size: 1.35rem;
  font-weight: 400;
  line-height: 1;
}

h1 {
  margin: 0;
  font-family: var(--heading);
  font-size: 2.42rem;
  font-weight: 400;
  line-height: 1.04;
}

.icon-button {
  min-width: 68px;
  height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 18px rgba(18, 32, 27, 0.08);
}

.setup-panel,
.form {
  display: grid;
  gap: 15px;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.setup-panel {
  margin-bottom: 14px;
}

.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-bottom: 14px;
}

.tab {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 254, 251, 0.72);
  font-size: 1.02rem;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(76, 47, 39, 0.06);
}

.tab.active {
  border-color: var(--brand);
  color: var(--panel);
  background: var(--brand);
}

.form {
  display: none;
}

.form.active {
  display: grid;
}

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

.field-title {
  margin: 2px 0 -5px;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  min-height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px 15px;
  color: var(--ink);
  background: #fffdf8;
  outline: none;
}

textarea {
  min-height: 86px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(138, 163, 122, 0.2);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 8px;
}

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

.status-grid input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.status-grid label {
  min-height: 58px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  color: var(--ink);
  font-size: 1.04rem;
  background: #fffdf8;
  text-align: center;
  box-shadow: 0 8px 18px rgba(76, 47, 39, 0.05);
}

.status-grid input:checked + label {
  border-color: var(--brand);
  color: var(--panel);
  background: var(--brand);
}

.primary-button,
.submit-button {
  min-height: 64px;
  border: 0;
  border-radius: 8px;
  color: var(--panel);
  background: var(--brand);
  font-size: 1.08rem;
  font-weight: 700;
  box-shadow: 0 14px 26px rgba(110, 137, 95, 0.22);
}

.submit-button {
  position: sticky;
  bottom: max(12px, env(safe-area-inset-bottom));
  margin-top: 4px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
}

.primary-button:disabled,
.submit-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 20;
  max-width: 528px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 8px;
  color: #fff;
  background: var(--ink);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  background: var(--danger);
}

@media (min-width: 620px) {
  .form {
    grid-template-columns: 1fr 1fr;
  }

  .status-grid,
  .wide,
  .submit-button {
    grid-column: 1 / -1;
  }
}
