:root {
  color-scheme: light;
  --paper: #f5f2ec;
  --surface: #fffdf8;
  --surface-soft: #faf7ef;
  --surface-quiet: #ece7dc;
  --ink: #20231e;
  --muted: #72766b;
  --moss: #436b4d;
  --moss-dark: #2e4d36;
  --line: rgba(32, 35, 30, 0.14);
  --shadow: 0 22px 70px rgba(42, 50, 38, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-height: 100svh;
  background:
    linear-gradient(135deg, rgba(67, 107, 77, 0.08), transparent 32%),
    linear-gradient(180deg, #fbfaf6 0%, var(--paper) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
  min-width: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  width: 100%;
  height: 100svh;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.app-topbar,
.app-bottombar {
  width: 100%;
  min-width: 0;
  background: rgba(255, 253, 248, 0.94);
  backdrop-filter: blur(18px);
  z-index: 20;
}

.app-topbar {
  position: relative;
  border-bottom: 1px solid var(--line);
}

.app-bottombar {
  border-top: 1px solid var(--line);
}

.topbar-main,
.topbar-steps,
.bottombar-inner,
.screen-view {
  width: min(1280px, 100%);
  margin: 0 auto;
}

.topbar-main {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 14px;
}

.brand-block {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid rgba(67, 107, 77, 0.34);
  border-radius: 7px;
  background: rgba(67, 107, 77, 0.12);
  color: var(--moss-dark);
  font-size: 13px;
  font-weight: 820;
}

.brand-copy {
  min-width: 0;
  display: grid;
  align-content: center;
  gap: 1px;
}

.brand-copy h1 {
  margin: 0;
  color: var(--ink);
  font-size: 18px;
  font-weight: 780;
  line-height: 1;
}

.brand-descriptor {
  margin: 0;
  color: var(--moss);
  font-size: 10px;
  font-weight: 760;
  line-height: 1.05;
  text-transform: uppercase;
}

.profile-block {
  position: relative;
  flex: 0 0 auto;
}

.profile-button {
  min-height: 32px;
  max-width: 220px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  color: var(--ink);
  padding: 3px 10px 3px 4px;
  font-size: 12px;
  font-weight: 750;
}

.profile-avatar {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(67, 107, 77, 0.14);
  color: var(--moss-dark);
  font-size: 12px;
  font-weight: 820;
}

.profile-avatar--large {
  width: 34px;
  height: 34px;
  font-size: 14px;
}

.profile-label {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.profile-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(360px, calc(100vw - 20px));
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.98);
  box-shadow: var(--shadow);
  padding: 14px;
  z-index: 60;
}

.profile-account {
  display: grid;
  gap: 12px;
}

.profile-account__head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.profile-account strong,
.profile-account p {
  margin: 0;
}

.profile-account strong {
  display: block;
  max-width: 250px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.profile-account p {
  color: var(--muted);
  font-size: 13px;
}

.topbar-steps {
  padding: 0 14px 7px;
}

.view-tabs {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-quiet);
  padding: 4px;
}

.view-tab {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  padding: 0 12px;
  font-size: 13px;
  font-weight: 760;
  transition:
    background 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.view-tab.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px rgba(67, 107, 77, 0.22);
}

.view-tab__num {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(67, 107, 77, 0.12);
  color: currentColor;
  font-size: 11px;
}

.app-center {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px 14px;
  scrollbar-gutter: stable;
}

.screen-view {
  min-height: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.82);
  box-shadow: var(--shadow);
  padding: 18px;
  animation: view-in 180ms ease both;
}

.planner-view {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.day-view {
  display: grid;
  align-content: start;
  gap: 16px;
}

.section-head h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(26px, 3.4vw, 42px);
  font-weight: 760;
  line-height: 1;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--moss);
  font-size: 12px;
  font-weight: 760;
  line-height: 1;
  text-transform: uppercase;
}

.day-toolbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
}

.date-control {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.date-input,
input {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  padding: 0 12px;
  outline: none;
}

.date-input:focus,
input:focus,
textarea:focus {
  border-color: rgba(67, 107, 77, 0.58);
  box-shadow: 0 0 0 3px rgba(67, 107, 77, 0.12);
}

textarea {
  width: 100%;
  flex: 1;
  min-height: 470px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffefb, #fbf8f1);
  color: var(--ink);
  padding: 18px;
  line-height: 1.55;
  outline: none;
}

textarea:disabled {
  opacity: 0.62;
}

.app-shell.has-preview textarea {
  flex: 0 0 auto;
  min-height: 220px;
}

.preview-panel {
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.preview-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
}

.preview-head h3,
.preview-head p {
  margin: 0;
}

.preview-head h3 {
  font-size: 20px;
  line-height: 1;
}

.preview-head > p {
  max-width: 320px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  text-align: right;
}

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

.bottombar-inner {
  min-height: 56px;
  display: grid;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
}

.screen-bottombar__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.screen-bottombar__actions--day {
  justify-content: space-between;
}

.primary-button,
.ghost-button,
.icon-button,
.status-button,
.auth-tab {
  min-height: 34px;
  border-radius: 8px;
  border: 1px solid transparent;
}

.primary-button {
  background: var(--moss);
  color: #fffdf8;
  border-color: var(--moss-dark);
  padding: 0 18px;
  font-weight: 760;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.ghost-button,
.icon-button,
.auth-tab {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.ghost-button {
  padding: 0 14px;
}

.status-line {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.35;
}

.status-line[data-tone="ok"] {
  color: var(--moss-dark);
}

.status-line[data-tone="error"] {
  color: #a9432e;
}

.auth-panel {
  display: grid;
  gap: 14px;
}

.auth-tabs {
  width: fit-content;
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-quiet);
}

.auth-tab {
  min-height: 34px;
  padding: 0 12px;
}

.auth-tab.is-active {
  background: var(--ink);
  color: var(--surface);
}

.auth-form {
  display: grid;
  gap: 10px;
}

.plan-list {
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 10px;
}

.plan-row {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  animation: row-in 180ms ease both;
}

.preview-row {
  background: linear-gradient(180deg, #fffefb, #faf8f1);
}

.plan-row.is-done {
  background: rgba(67, 107, 77, 0.08);
}

.plan-row__main {
  min-width: 0;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
}

.status-button,
.icon-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.status-button {
  color: var(--moss);
  font-size: 22px;
  font-weight: 800;
}

.item-title {
  width: 100%;
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  padding: 0 2px;
  font-weight: 650;
}

.item-meta {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 96px minmax(120px, 0.8fr);
  gap: 8px;
  padding-left: 44px;
}

.item-meta input {
  width: 100%;
  min-height: 36px;
  padding: 0 8px;
  font-size: 13px;
}

.time-text {
  min-width: 0;
}

.empty-state {
  color: var(--muted);
  line-height: 1.45;
}

.empty-state p {
  margin: 0;
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 720px) {
  .topbar-main {
    min-height: 40px;
    padding: 5px 10px;
  }

  .topbar-steps {
    padding: 0 10px 6px;
  }

  .brand-mark {
    width: 28px;
    height: 28px;
  }

  .brand-copy h1 {
    font-size: 17px;
  }

  .brand-descriptor {
    font-size: 9px;
  }

  .profile-button {
    max-width: 150px;
    padding-right: 8px;
  }

  .view-tab {
    min-height: 30px;
    gap: 6px;
    padding: 0 8px;
    font-size: 12px;
  }

  .view-tab__num {
    width: 18px;
    height: 18px;
    font-size: 10px;
  }

  .app-center {
    padding: 10px;
  }

  .screen-view {
    min-height: auto;
    padding: 14px;
  }

  .day-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .date-control {
    width: 100%;
  }

  .date-input {
    width: 100%;
  }

  textarea {
    min-height: 420px;
  }

  .bottombar-inner {
    padding: 9px 10px;
    padding-bottom: max(9px, env(safe-area-inset-bottom));
  }

  .screen-bottombar__actions,
  .screen-bottombar__actions--day {
    align-items: stretch;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  #bottombarPlanner .screen-bottombar__actions {
    grid-template-columns: 1fr auto;
  }

  .preview-head {
    align-items: start;
    flex-direction: column;
    gap: 6px;
  }

  .preview-head > p {
    max-width: none;
    text-align: left;
  }

  .plan-row {
    padding: 10px;
  }

  .plan-row__main {
    grid-template-columns: 36px minmax(0, 1fr) 36px;
  }

  .item-meta {
    padding-left: 44px;
    grid-template-columns: minmax(0, 1fr) 92px;
  }

  .time-text {
    grid-column: 1 / 3;
  }

  .section-head h2 {
    font-size: 28px;
  }
}

@media (max-width: 380px) {
  .profile-label {
    max-width: 72px;
  }

  .view-tab {
    font-size: 11px;
    padding: 0 6px;
  }
}
