:root{
  --bg:#DDDAD4; --surface:#F7F6F3; --surface2:#E9E7E2; --ink:#161616; --black:#1C1C1C;
  --muted:#57534D; --accent:#B8A3EC; --green:#3F7D5A; --red:#D9261C; --grey:#BEBEBE;
  --r-card:28px; --r-btn:20px; --r-field:16px; --r-icon:14px; --r-badge:10px;
  --display:'Inter Tight','Inter',system-ui,sans-serif; --text:'Inter',system-ui,sans-serif; --serif:'Source Serif 4',Georgia,serif;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html,body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--text);-webkit-font-smoothing:antialiased}
body{min-height:100dvh}
a{color:inherit;text-decoration:none}
button,input,textarea{font-family:inherit;color:inherit}
button{cursor:pointer}
h1,h2,h3,p{margin:0}
:focus-visible{outline:3px solid var(--accent);outline-offset:2px}
#app{max-width:430px;margin:0 auto;min-height:100dvh;position:relative}
.screen{min-height:100dvh;display:flex;flex-direction:column;padding:calc(env(safe-area-inset-top) + 16px) 20px calc(env(safe-area-inset-bottom) + 24px)}
.screen.has-nav{padding-bottom:calc(env(safe-area-inset-bottom) + 112px)}
.grow{flex:1}
.row{display:flex;align-items:center}
.between{justify-content:space-between}
.gap8{gap:8px}.gap12{gap:12px}
.mt4{margin-top:4px}.mt8{margin-top:8px}.mt12{margin-top:12px}.mt16{margin-top:16px}.mt20{margin-top:20px}.mt24{margin-top:24px}.mt28{margin-top:28px}
.muted{color:var(--muted)}
.small{font-size:12px;line-height:1.4}
.topbar{display:flex;align-items:center;justify-content:space-between;min-height:44px;gap:12px}
.h1{font-family:var(--display);font-weight:800;font-size:44px;line-height:1;letter-spacing:-.03em;margin-top:20px}
.h1.hero{font-size:52px;line-height:.98;letter-spacing:-.035em}
.lead{margin-top:12px;font-size:15px;line-height:1.45;color:var(--muted)}
.label{font-size:12px;font-weight:600;color:var(--muted)}

.btn{display:flex;align-items:center;justify-content:center;gap:10px;width:100%;height:56px;border:0;border-radius:var(--r-btn);background:var(--black);color:var(--surface);font-size:16px;font-weight:600}
.btn:disabled{opacity:.45;cursor:default}
.btn.ghost{background:transparent;border:2px solid var(--ink);color:var(--ink)}
.btn.sm{height:48px;font-size:14px}
.btn.inline{width:auto;padding:0 18px}
.linkbtn{display:flex;align-items:center;justify-content:center;min-height:48px;border:0;background:transparent;font-size:14px;font-weight:600;text-decoration:underline}
.iconbtn{position:relative;flex:none;width:44px;height:44px;border:0;border-radius:var(--r-icon);background:var(--surface);display:flex;align-items:center;justify-content:center;color:var(--ink)}
.iconbtn.dark{background:var(--black);color:var(--surface);font-family:var(--display);font-weight:700;font-size:16px}
.iconbtn svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
.ping{position:absolute;top:9px;right:10px;width:10px;height:10px;border-radius:50%;background:var(--accent);box-shadow:0 0 0 2px var(--surface),0 0 0 3.5px var(--ink)}

.field{display:flex;flex-direction:column;gap:6px;font-size:12px;font-weight:600;color:var(--muted)}
.field input,.field textarea,.input{width:100%;min-height:52px;padding:0 16px;border:0;border-radius:var(--r-field);background:var(--surface);font-size:16px;color:var(--ink)}
.field textarea{padding:12px 16px;min-height:88px;resize:none;line-height:1.4}
.field input::placeholder,.field textarea::placeholder{color:#7a756d}
.field.err input{box-shadow:0 0 0 2px var(--red)}
.errtext{margin-top:8px;font-size:13px;line-height:1.4;color:var(--red);font-weight:600}
.codeinput{height:64px!important;font-family:var(--display);font-size:32px!important;font-weight:700;letter-spacing:.35em;text-align:center}

.seg{display:flex;gap:4px;padding:4px;border-radius:var(--r-btn);background:rgba(247,246,243,.7)}
.seg button{flex:1;min-height:44px;border:0;border-radius:16px;background:transparent;font-size:13px;font-weight:600}
.seg button[aria-selected=true]{background:var(--black);color:var(--surface)}
.search{display:flex;align-items:center;gap:10px;min-height:52px;padding:0 16px;border-radius:var(--r-field);background:var(--surface)}
.search input{flex:1;min-width:0;height:48px;border:0;outline:0;background:transparent;font-size:15px}
.search svg{width:20px;height:20px;flex:none;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round}
.chips{display:flex;gap:8px;overflow-x:auto;padding-bottom:2px;scrollbar-width:none}
.chips::-webkit-scrollbar{display:none}
.chip{flex:none;min-height:44px;padding:0 16px;border:0;border-radius:16px;background:var(--surface);font-size:13px;font-weight:600;white-space:nowrap}
.chip[aria-pressed=true]{background:var(--black);color:var(--surface)}
.badge{display:inline-flex;align-items:center;gap:6px;padding:4px 10px;border-radius:var(--r-badge);font-size:11px;font-weight:600;background:var(--surface)}
.badge.accent{background:var(--accent);color:var(--ink)}
.dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none;box-shadow:0 0 0 2px rgba(247,246,243,.85)}
.dot.ok{background:var(--green)}.dot.ink{background:var(--black)}.dot.ill{width:10px;height:10px;background:var(--accent);box-shadow:0 0 0 1.5px var(--ink)}
.dot.red{background:var(--red)}

/* Полки */
.shelf{margin-bottom:28px}
.shelf-head{display:flex;align-items:center;gap:10px;margin-bottom:12px}
.avatar{display:flex;align-items:center;justify-content:center;width:32px;height:32px;border-radius:50%;font-family:var(--display);font-size:14px;font-weight:700;flex:none}
.shelf-name{font-size:16px;font-weight:700;line-height:1.2}
.books{display:flex;align-items:flex-end;gap:5px;overflow-x:auto;padding-top:10px;scrollbar-width:none}
.books::-webkit-scrollbar{display:none}
.spine{position:relative;flex:none;display:flex;flex-direction:column;align-items:center;justify-content:space-between;height:190px;padding:12px 0 10px;border-radius:4px;box-shadow:0 1px 2px rgba(22,22,22,.18);transform-origin:0 100%;border:0;color:var(--ink)}
.spine.lent{background:var(--grey)!important;color:#3A3A3A;transform:rotate(6deg);margin:0 24px 0 6px}
.spine b{font-weight:400;writing-mode:vertical-rl;font-family:var(--serif);font-size:12px;line-height:1.15;max-height:136px;overflow:hidden}
.spine.hasill b{margin-top:12px}
.spine i{border-radius:50%;background:radial-gradient(circle at 35% 30%,rgba(247,246,243,.6),rgba(22,22,22,.6))}
.spine .dot.ill{position:absolute;top:8px;left:50%;margin-left:-5px}
.plank{height:6px;border-radius:3px;background:var(--black)}
.emptyshelf{padding:18px 0;font-size:13px;color:var(--muted)}

.grid2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}
.tile{position:relative;display:flex;flex-direction:column;justify-content:space-between;height:176px;padding:14px;border-radius:var(--r-card);text-align:left;border:0;color:var(--ink)}
.tile .a{font-size:11px;font-weight:600;letter-spacing:.08em;text-transform:uppercase;line-height:1.2}
.tile .t{margin-top:6px;font-family:var(--serif);font-size:19px;font-weight:600;line-height:1.1;display:-webkit-box;-webkit-line-clamp:3;-webkit-box-orient:vertical;overflow:hidden}
.tile .m{font-size:11px;font-weight:600;line-height:1.6}
.tile .dot.ill{position:absolute;top:12px;right:12px;width:12px;height:12px}

/* Стопка цветных полей */
.stack{display:flex;flex-direction:column}
.stack>.card{position:relative;display:block;width:100%;min-height:146px;margin-top:-34px;padding:16px 20px;border:0;border-radius:var(--r-card);text-align:left;color:var(--ink);box-shadow:0 -2px 8px rgba(22,22,22,.06)}
.stack>.card:first-child{margin-top:0}
.card .k{font-size:12px}
.card .big{margin-top:2px;font-family:var(--display);font-weight:700;font-size:22px;line-height:1.1;letter-spacing:-.02em}
.card .sub{margin-top:4px;font-size:12px}
.card .side{position:absolute;top:16px;right:20px;display:flex;flex-direction:column;align-items:flex-end;gap:6px;font-size:13px;font-weight:600}
.card.tall{min-height:270px}
.card.last{padding-bottom:22px}

.bignum{margin-top:20px;font-family:var(--display);font-weight:800;font-size:150px;line-height:.85;letter-spacing:-.05em}
.dots{display:grid;gap:8px;margin-top:8px;justify-items:center}
.dots span{border-radius:50%}
.legend{display:flex;flex-wrap:wrap;gap:8px 16px;margin-top:16px;font-size:12px}
.legend span{display:flex;align-items:center;gap:6px}
.legend i{width:10px;height:10px;border-radius:50%;display:inline-block}

.panel{padding:18px 20px;border-radius:var(--r-card);background:var(--surface)}
.panel.pad14{padding:14px 16px;border-radius:20px}
.photo{position:relative;flex:none;width:96px;height:128px;border-radius:16px;overflow:hidden}
.photo span{position:absolute;left:8px;bottom:8px;padding:3px 8px;border-radius:var(--r-badge);background:rgba(247,246,243,.92);font-size:11px;font-weight:600}
.hscroll{display:flex;gap:10px;overflow-x:auto;scrollbar-width:none}

/* Нижняя панель */
.nav{position:fixed;left:50%;transform:translateX(-50%);bottom:calc(env(safe-area-inset-bottom) + 16px);width:calc(100% - 40px);max-width:390px;height:64px;padding:0 20px;border-radius:var(--r-btn);background:var(--black);display:flex;align-items:center;justify-content:space-between;z-index:20}
.nav a{display:flex;align-items:center;min-height:44px;padding:0 8px;font-size:11px;font-weight:600;letter-spacing:.08em;color:rgba(247,246,243,.65);text-transform:uppercase}
.nav a[aria-current=page]{color:var(--surface)}
.nav .plus{width:44px;height:44px;padding:0;justify-content:center;border-radius:16px;background:var(--surface);color:var(--ink)}
.nav .plus svg{width:22px;height:22px;stroke:currentColor;fill:none;stroke-width:2.2;stroke-linecap:round}
.dock{position:fixed;left:50%;transform:translateX(-50%);bottom:0;width:100%;max-width:430px;padding:16px 20px calc(env(safe-area-inset-bottom) + 24px);background:linear-gradient(180deg,rgba(221,218,212,0),var(--bg) 30%);z-index:10}

/* Лист снизу */
.overlay{position:fixed;inset:0;background:rgba(22,22,22,.45);z-index:40;display:flex;align-items:flex-end;justify-content:center}
.sheet{width:100%;max-width:430px;max-height:92dvh;overflow-y:auto;padding:12px 20px calc(env(safe-area-inset-bottom) + 24px);border-radius:28px 28px 0 0;background:var(--surface)}
.sheet .grab{width:40px;height:4px;margin:0 auto;border-radius:2px;background:rgba(22,22,22,.2)}
.sheet .field input,.sheet .field textarea{background:var(--surface2)}
.sheet .panel{background:var(--surface2)}

.demo{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:-4px 0 12px;padding:8px 8px 8px 14px;border-radius:var(--r-icon);background:var(--black);color:var(--surface);font-size:12px;font-weight:600}
.demo button{color:var(--ink);min-height:36px;padding:0 12px;border:0;border-radius:10px;background:var(--surface);font-size:12px;font-weight:600}

.skel{border-radius:var(--r-card);background:linear-gradient(90deg,rgba(247,246,243,.5),rgba(247,246,243,.9),rgba(247,246,243,.5));background-size:200% 100%;animation:sk 1.4s linear infinite}
@keyframes sk{from{background-position:200% 0}to{background-position:-200% 0}}
.empty{padding:36px 0;text-align:center}
.empty .t{font-family:var(--display);font-size:24px;font-weight:800;letter-spacing:-.02em}
.empty .s{margin-top:8px;font-size:14px;color:var(--muted)}
#toast{position:fixed;left:50%;bottom:calc(env(safe-area-inset-bottom) + 96px);transform:translate(-50%,20px);max-width:min(380px,calc(100% - 40px));padding:12px 16px;border-radius:var(--r-icon);background:var(--black);color:var(--surface);font-size:14px;font-weight:600;opacity:0;pointer-events:none;transition:.2s;z-index:60}
#toast.show{opacity:1;transform:translate(-50%,0)}

/* Сканер */
.scanner{background:linear-gradient(180deg,#2B2824,#161616 70%);color:var(--surface)}
.scanner .iconbtn{background:rgba(247,246,243,.14);color:var(--surface)}
.viewfinder{position:relative;width:min(310px,100%);height:180px;margin:48px auto 0;overflow:hidden;border-radius:20px;background:#0c0c0c}
.viewfinder video{position:absolute;inset:0;width:100%;height:100%;object-fit:cover}
.viewfinder::before,.viewfinder::after{content:"";position:absolute;left:12px;right:12px;height:3px;border-radius:2px;background:var(--accent);top:50%;z-index:2;animation:scan 2s ease-in-out infinite alternate}
.viewfinder::after{display:none}
@keyframes scan{from{top:20%}to{top:80%}}
.corner{position:absolute;width:36px;height:36px;border:0 solid var(--surface);z-index:3}
.c1{top:0;left:0;border-width:4px 0 0 4px;border-top-left-radius:20px}
.c2{top:0;right:0;border-width:4px 4px 0 0;border-top-right-radius:20px}
.c3{bottom:0;left:0;border-width:0 0 4px 4px;border-bottom-left-radius:20px}
.c4{bottom:0;right:0;border-width:0 4px 4px 0;border-bottom-right-radius:20px}
.scanner .field input{background:var(--surface)}
.scanner .field{color:rgba(247,246,243,.8)}
.found{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:14px 16px 14px 18px;border-radius:24px;background:var(--surface);color:var(--ink);text-align:left;width:100%;border:0}
.found .t{font-family:var(--serif);font-size:18px;font-weight:600}
.switch{display:flex;align-items:center;justify-content:space-between;gap:12px;min-height:56px;padding:8px 16px;border-radius:var(--r-field);background:var(--surface)}
.switch input{width:22px;height:22px;accent-color:var(--black)}
.cover{flex:none;width:84px;height:126px;border-radius:8px;padding:10px;display:flex;flex-direction:column;justify-content:space-between;box-shadow:0 6px 14px rgba(22,22,22,.14);color:var(--ink);overflow:hidden;background-size:cover;background-position:center}
.cover .a{font-size:8px;font-weight:600;letter-spacing:.08em;text-transform:uppercase}
.cover .t{font-family:var(--serif);font-size:15px;font-weight:600;line-height:1}
.swatch{width:44px;height:44px;border-radius:var(--r-icon);border:3px solid transparent}
.swatch[aria-pressed=true]{border-color:var(--black)}
.inviteCode{margin-top:2px;font-family:var(--display);font-weight:800;font-size:40px;letter-spacing:.12em}
.member{display:flex;align-items:center;gap:12px;min-height:56px;padding:6px 0}
.member .nm{flex:1;min-width:0}
.member .nm b{display:block;font-size:15px}
.reqcard{padding:14px 16px;border-radius:20px;background:var(--surface);margin-top:10px}
.pill-row{display:flex;gap:8px;margin-top:12px}
@media (prefers-reduced-motion:reduce){.viewfinder::before,.skel{animation:none}#toast{transition:none}}
@media (min-width:431px){body{background:#cfccc5}#app{background:var(--bg);box-shadow:0 0 0 1px rgba(22,22,22,.06)}}

.btn svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;flex:none}
