/* WaloRent - в духе «Системных настроек» macOS: боковой список, сгруппированные строки, плитки-иконки.
   Светлая и тёмная тема: data-theme на <html> (auto берёт тему Telegram или системы). */
:root {
  --win: #ececec; --side: #e3e3e6; --pane: #f5f5f7; --group: #ffffff; --line: rgba(0,0,0,.09);
  --text: #1d1d1f; --sub: #6e6e73; --faint: #a1a1a6; --accent: #0a64d8; --accent-text: #fff;
  --sel: #0a64d8; --sel-text: #fff; --field: #ffffff; --field-line: rgba(0,0,0,.16); --danger: #d70015; --ok: #248a3d;
  --switch-off: #d9d9de; --knob: #fff;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --win: #1e1e1e; --side: #262628; --pane: #1e1e1e; --group: #2c2c2e; --line: rgba(255,255,255,.08);
  --text: #f2f2f7; --sub: #98989d; --faint: #636366; --accent: #3b8ef0; --sel: #2f6fcf;
  --field: #1c1c1e; --field-line: rgba(255,255,255,.14); --danger: #ff6961; --ok: #30d158; --switch-off: #48484a; --knob: #e5e5ea;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--pane); color: var(--text); font: 15px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }

.app { display: flex; min-height: 100%; }
.side { width: 100%; background: var(--side); padding: 10px 10px 40px; }
.pane { width: 100%; background: var(--pane); padding: 0 16px 48px; display: none; }
.app.detail .side { display: none; }
.app.detail .pane { display: block; }
@media (min-width: 760px) {
  .side { width: 260px; flex: none; border-right: 1px solid var(--line); min-height: 100vh; position: sticky; top: 0; align-self: flex-start; }
  .pane, .app.detail .pane { display: block; max-width: 640px; }
  .app.detail .side { display: block; }
  .back { display: none !important; }
}

/* поиск и карточка профиля в боковом списке */
.search { width: 100%; border: 0; border-radius: 7px; padding: 6px 10px; background: rgba(120,120,128,.14); color: var(--text); font-size: 14px; margin: 2px 0 10px; outline: none; }
.me { display: flex; gap: 10px; align-items: center; padding: 8px; border-radius: 8px; margin-bottom: 10px; cursor: pointer; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: #8e8e93; color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 15px; flex: none; }
.me b { display: block; font-size: 14px; }
.me span { font-size: 12px; color: var(--sub); }

.nav { margin: 0 0 12px; }
.nav button { width: 100%; display: flex; align-items: center; gap: 9px; border: 0; background: none; padding: 5px 8px; border-radius: 7px; text-align: left; font-size: 14px; cursor: pointer; }
.nav button.on { background: var(--sel); color: var(--sel-text); }
.tile { width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; flex: none; }
.tile svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* правая часть */
.bar { position: sticky; top: 0; background: var(--pane); display: flex; align-items: center; gap: 6px; padding: 12px 0 10px; z-index: 2; }
.bar h1 { font-size: 17px; font-weight: 600; margin: 0; }
.back { border: 0; background: none; color: var(--accent); padding: 4px 6px 4px 0; font-size: 22px; line-height: 1; cursor: pointer; }
.head { display: flex; gap: 12px; align-items: center; margin: 4px 0 16px; }
.head .tile { width: 44px; height: 44px; border-radius: 11px; }
.head .tile svg { width: 26px; height: 26px; }
.head b { font-size: 15px; display: block; }
.head p { margin: 2px 0 0; font-size: 13px; color: var(--sub); }

.caption { font-size: 12px; color: var(--sub); margin: 18px 4px 6px; }
.note { font-size: 12px; color: var(--sub); margin: 6px 4px 0; }
.group { background: var(--group); border-radius: 10px; border: 1px solid var(--line); overflow: hidden; }
.row { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 8px 12px; position: relative; width: 100%; border: 0; background: none; text-align: left; }
.row + .row::before { content: ""; position: absolute; top: 0; left: 12px; right: 0; border-top: 1px solid var(--line); }
.row .tile + .grow { }
.row .grow { flex: 1; min-width: 0; }
.row .grow small { display: block; color: var(--sub); font-size: 12px; }
.row .val { color: var(--sub); font-size: 14px; white-space: nowrap; }
.row.link { cursor: pointer; }
.row.link::after { content: "›"; color: var(--faint); font-size: 20px; line-height: 1; margin-left: 2px; }
.row.off { color: var(--faint); }
.row.off .val { color: var(--faint); }
.mark { width: 16px; text-align: center; color: var(--faint); }
.mark.done { color: var(--ok); }

/* сегментный переключатель темы */
.seg { display: inline-flex; background: rgba(120,120,128,.16); border-radius: 7px; padding: 2px; }
.seg button { border: 0; background: none; padding: 3px 10px; border-radius: 5px; font-size: 13px; cursor: pointer; }
.seg button.on { background: var(--group); box-shadow: 0 0 0 .5px var(--line), 0 1px 2px rgba(0,0,0,.12); }

/* переключатель */
.switch { width: 38px; height: 22px; border-radius: 11px; background: var(--switch-off); position: relative; border: 0; flex: none; cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--knob); box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(16px); }

/* поля и кнопки */
.field { width: 100%; border: 1px solid var(--field-line); background: var(--field); color: var(--text); border-radius: 6px; padding: 6px 8px; font: inherit; font-size: 14px; outline: none; }
.field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.row .field { max-width: 55%; text-align: right; }
textarea.field { min-height: 90px; text-align: left; resize: vertical; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 10px; flex-wrap: wrap; }
.btn { border: 1px solid var(--field-line); background: var(--group); border-radius: 6px; padding: 5px 12px; font-size: 14px; cursor: pointer; }
.btn.main { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); }
.msg { padding: 10px 12px; }
.msg + .msg { border-top: 1px solid var(--line); }
.msg small { color: var(--sub); display: block; font-size: 12px; margin-bottom: 2px; }
.empty { color: var(--sub); font-size: 13px; padding: 12px; }

.me .avatar { color: #fff; font-size: 15px; }
/* телефон: разделы - сгруппированными списками, как в настройках iPhone */
@media (max-width: 759px) {
  .side { background: var(--pane); padding: 12px 16px 40px; }
  .me { background: var(--group); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
  .nav { background: var(--group); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin-bottom: 18px; }
  .nav button { border-radius: 0; padding: 9px 12px; font-size: 15px; position: relative; }
  .nav button + button::before { content: ""; position: absolute; top: 0; left: 44px; right: 0; border-top: 1px solid var(--line); }
  .nav button::after, .me::after { content: "›"; margin-left: auto; color: var(--faint); font-size: 20px; line-height: 1; }
  .nav button.on { background: none; color: inherit; }
  .tile { width: 26px; height: 26px; border-radius: 7px; }
  .tile svg { width: 16px; height: 16px; }
}

/* ---- телефон - основной сценарий: крупнее строки, шрифт 17, поля без автоувеличения на iPhone ---- */
@media (max-width: 759px) {
  body { font-size: 17px; }
  .pane { padding: 0 16px calc(48px + env(safe-area-inset-bottom)); }
  .bar { padding: 14px 0 6px; }
  .bar h1 { font-size: 30px; font-weight: 700; letter-spacing: -.3px; }
  .head.sec { margin: 0 0 4px; } .head.sec .tile, .head.sec b { display: none; } .head.sec p { font-size: 15px; margin: 0 2px; }
  .row { min-height: 48px; padding: 10px 14px; }
  .row .grow small, .note, .caption { font-size: 13px; }
  .row .val { font-size: 17px; }
  .caption { margin: 22px 14px 7px; text-transform: uppercase; letter-spacing: .2px; }
  .note { margin: 7px 14px 0; }
  .field, .search { font-size: 17px; }
  .search { padding: 8px 12px; border-radius: 10px; }
  .row .field { max-width: 42%; border: 0; background: none; padding: 4px 0; color: var(--sub); }
  .row .field:focus { box-shadow: none; color: var(--text); }
  .btn { padding: 9px 16px; font-size: 16px; border-radius: 10px; }
  .actions { justify-content: stretch; }
  .actions .btn { flex: 1; }
  .switch { width: 51px; height: 31px; border-radius: 16px; }
  .switch::after { width: 27px; height: 27px; }
  .switch.on::after { transform: translateX(20px); }
  .seg button { padding: 6px 12px; font-size: 14px; }
  .me .avatar { width: 52px; height: 52px; font-size: 19px; }
  .me b { font-size: 18px; } .me span { font-size: 14px; }
}
/* нижний лист для ввода */
.sheet-wrap { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { width: 100%; max-width: 520px; background: var(--group); border-radius: 14px 14px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-title { font-weight: 600; margin-bottom: 10px; }
.sheet .field { font-size: 17px; padding: 10px 12px; border-radius: 10px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 12px; }
.sheet-actions .btn { flex: 1; padding: 11px; font-size: 17px; border-radius: 10px; }
@media (min-width: 760px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 14px; } }
