:root {
  --screen: #f4f6f4;
  --surface: #ffffff;
  --ink: #1e2823;
  --muted: #6b756f;
  --line: #e2e7e3;
  --accent: #3f5c4e;
  --accent-soft: #e7eee9;
  --warn: #8a6a3a;
  --warn-soft: #f3ecdf;
  --danger: #8b4a45;
  --danger-soft: #f3e6e5;
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  background: var(--screen);
  color: var(--ink);
  overscroll-behavior-y: none;
}

body {
  font-size: 16px;
  line-height: 1.4;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
}
button { cursor: pointer; }
button:active { transform: scale(0.99); }

.app, .shell { height: 100%; }
.boot {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.hidden { display: none !important; }

.stage { height: 100%; }

.screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* —— App bar —— */
.bar {
  padding: calc(var(--safe-top) + 10px) 8px 10px 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  background: var(--screen);
}
.bar h2 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 1;
}
.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: var(--ink);
  flex-shrink: 0;
}
.icon-btn svg { width: 21px; height: 21px; }
.icon-btn.on, .icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.spacer { width: 42px; flex-shrink: 0; }

.scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 14px 24px;
  -webkit-overflow-scrolling: touch;
}
.scroll.pad-bottom { padding-bottom: calc(28px + var(--safe-bottom)); }

/* —— Home —— */
.home {
  background: linear-gradient(170deg, #eef1ee 0%, #e4e9e5 55%, #dde4df 100%);
}
.home-top {
  padding: calc(var(--safe-top) + 18px) 18px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.home-hello {
  font-size: 14px;
  color: var(--muted);
}
.home-hello strong {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.02em;
  margin-top: 2px;
}
.home-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
  padding: 18px;
  min-height: 0;
  overflow-y: auto;
}
.next-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: left;
  width: 100%;
}
.next-card .lab {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.next-card .title {
  font-size: 17px;
  font-weight: 650;
  margin-top: 6px;
}
.next-card .meta {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}
.widget {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 26px;
  padding: 18px 12px 14px;
  box-shadow: 0 10px 28px rgba(20, 30, 25, 0.08);
}
.widget-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.w-cap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.w-cap span {
  font-size: 12px;
  font-weight: 650;
  color: var(--ink);
  opacity: 0.75;
}
.w-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
}
.w-btn svg { width: 26px; height: 26px; }
.w-btn.primary {
  width: 76px;
  height: 76px;
  background: var(--accent);
  color: #f4f6f4;
  box-shadow: 0 8px 20px rgba(63, 92, 78, 0.28);
}
.w-btn.primary svg { width: 30px; height: 30px; }

.incoming-banner {
  background: var(--warn-soft);
  border: 1px solid rgba(138, 106, 58, 0.22);
  color: var(--warn);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  width: 100%;
}

/* —— Cards —— */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  text-align: left;
  width: 100%;
  display: block;
}
.card .row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}
.card .title { font-size: 16px; font-weight: 650; line-height: 1.3; }
.card.done .title { text-decoration: line-through; color: var(--muted); }
.card .meta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  white-space: nowrap;
}
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.soft { background: var(--screen); color: var(--muted); }
.empty {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  padding: 48px 16px;
  line-height: 1.5;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 0 12px 10px;
  flex-shrink: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 8px 13px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
  white-space: nowrap;
}
.tab.on { background: var(--accent-soft); color: var(--accent); }

.tabs-line {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}
.tabs-line .tab { flex: 1; text-align: center; }

/* —— Chat —— */
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.bubble {
  max-width: 92%;
  border-radius: 16px;
  padding: 12px 14px;
  font-size: 15px;
}
.bubble.me {
  align-self: flex-end;
  background: var(--accent);
  color: #f4f6f4;
  border-bottom-right-radius: 6px;
}
.bubble.ai {
  align-self: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.bubble.ai strong {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 6px;
}
.ai-line { font-size: 14px; }
.ai-bell { margin-top: 8px; font-size: 12px; color: var(--muted); }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font-size: 13px;
  font-weight: 650;
  padding: 8px 11px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
}
.chip.ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }

.composer {
  border-top: 1px solid var(--line);
  padding: 10px 12px calc(12px + var(--safe-bottom));
  display: flex;
  gap: 8px;
  align-items: center;
  background: var(--screen);
  flex-shrink: 0;
}
.composer input {
  flex: 1;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: 13px 14px;
  outline: none;
  min-width: 0;
}
.composer input:focus { border-color: #b7c4bc; }
.composer .round {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  background: var(--accent);
  color: #f4f6f4;
}
.composer .round.soft { background: var(--accent-soft); color: var(--accent); }
.composer .round svg { width: 20px; height: 20px; }

/* —— Record —— */
.record {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
}
.rec-ring {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
  position: relative;
  color: var(--accent);
}
.rec-ring svg { width: 40px; height: 40px; }
.rec-ring.live::after {
  content: "";
  position: absolute;
  inset: -12px;
  border-radius: 50%;
  border: 2px solid rgba(63, 92, 78, 0.3);
  animation: pulse 1.4s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.65; }
  50% { transform: scale(1.07); opacity: 1; }
}
.rec-text {
  font-size: 16px;
  color: var(--ink);
  min-height: 48px;
  max-width: 320px;
}
.rec-text.dim { color: var(--muted); }
.rec-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }

.btn {
  padding: 13px 18px;
  border-radius: 14px;
  font-size: 15px;
  font-weight: 650;
  background: var(--accent);
  color: #f4f6f4;
}
.btn.ghost { background: var(--surface); color: var(--ink); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.btn[disabled] { opacity: 0.5; }

/* —— Fields —— */
.field { display: block; margin-bottom: 12px; }
.field > span, .field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.field input, .field select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 12px;
  padding: 13px 12px;
  outline: none;
}
.field input:focus { border-color: #b7c4bc; }
.actions-col { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

/* —— Wheel picker —— */
.pick-block {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}
.pick-block.open { border-color: #b7c4bc; }
.pick-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 12px;
  text-align: left;
}
.pick-head .lab {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 62px;
}
.pick-head .val { flex: 1; font-size: 16px; font-weight: 650; }
.pick-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.pick-block.open .pick-ico { background: var(--accent); color: #f4f6f4; }
.pick-ico svg { width: 19px; height: 19px; }
.pick-body {
  display: none;
  padding: 0 8px 14px;
  border-top: 1px solid var(--line);
}
.pick-block.open .pick-body { display: block; }
.wheels {
  display: flex;
  gap: 6px;
  position: relative;
  height: 180px;
  margin-top: 10px;
}
.wheels::before {
  content: "";
  position: absolute;
  left: 4px;
  right: 4px;
  top: 50%;
  height: 40px;
  transform: translateY(-50%);
  background: var(--accent-soft);
  border-radius: 10px;
  pointer-events: none;
}
.wheel {
  flex: 1;
  height: 180px;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  position: relative;
  z-index: 1;
  scrollbar-width: none;
}
.wheel::-webkit-scrollbar { display: none; }
.wheel-pad { height: 70px; }
.wheel-item {
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  color: var(--muted);
  opacity: 0.45;
  scroll-snap-align: center;
}
.wheel-item.on { color: var(--ink); opacity: 1; font-weight: 700; }
.pick-hint {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}

/* —— Settings —— */
.setting {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
}
.setting .name { font-size: 15px; font-weight: 600; }
.setting .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.group-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 18px 2px 8px;
}
.toggle {
  width: 44px;
  height: 27px;
  border-radius: 999px;
  background: #c5cdc8;
  position: relative;
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); }
.toggle i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}
.toggle.on i { left: 20px; }

.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1;
  padding: 9px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 650;
  background: var(--surface);
}
.seg button.on { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

.code-box {
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 14px;
  text-align: center;
  margin-bottom: 12px;
}
.code-box .code {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--accent);
}
.code-box .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.person {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  width: 100%;
  text-align: left;
  margin-bottom: 8px;
}
.person.on { border-color: var(--accent); background: var(--accent-soft); }
.check {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 1.5px solid #aab4ad;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  font-size: 13px;
}
.person.on .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.person .who { flex: 1; }
.person .who b { font-size: 15px; font-weight: 650; }
.person .who small { display: block; font-size: 12px; color: var(--muted); }

/* —— Auth —— */
.auth { justify-content: center; }
.auth-inner {
  padding: 24px 20px calc(24px + var(--safe-bottom));
  max-width: 420px;
  margin: 0 auto;
  width: 100%;
}
.brand { text-align: center; margin-bottom: 24px; }
.brand-mark {
  width: 62px;
  height: 62px;
  border-radius: 20px;
  background: var(--accent);
  color: #f4f6f4;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
}
.brand-mark svg { width: 28px; height: 28px; }
.brand h1 { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.brand p { color: var(--muted); font-size: 14px; margin-top: 6px; }
.auth-form .note { font-size: 12px; color: var(--muted); margin-top: 12px; line-height: 1.5; }
.auth-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }

/* —— Toast —— */
.toast {
  position: fixed;
  left: 14px;
  right: 14px;
  bottom: calc(18px + var(--safe-bottom));
  background: var(--ink);
  color: #f4f6f4;
  padding: 13px 14px;
  border-radius: 14px;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  z-index: 60;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateY(0); }

.offline-bar {
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 12px;
  font-weight: 650;
  text-align: center;
  padding: 7px 12px;
}

/* На большом экране показываем приложение как телефон, чтобы верстка не растягивалась */
@media (min-width: 680px) {
  body {
    display: grid;
    place-items: center;
    background: #e6eae7;
    padding: 24px;
  }
  .app {
    width: 400px;
    height: min(840px, calc(100vh - 48px));
    background: var(--screen);
    border: 1px solid var(--line);
    border-radius: 30px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(30, 40, 35, 0.16);
  }
  .toast {
    left: 50%;
    right: auto;
    transform: translate(-50%, 10px);
    width: 340px;
  }
  .toast.show { transform: translate(-50%, 0); }
}
