:root{
  --bg:#0b0c0f;
  --bg2:#08090c;
  --text:rgba(255,255,255,.92);
  --muted:rgba(255,255,255,.52);

  --line:rgba(255,255,255,.09);
  --card:rgba(255,255,255,.032);

  --accent:#2ea6ff;
  --accentSoft:rgba(46,166,255,.16);
  --accentGlow:rgba(46,166,255,.32);
  --ok:#44ff9a;
  --warn:#ffd24d;
  --err:#ff5c7a;
  --premium:#ffb800;
  --premiumGlow:rgba(255,184,0,.22);

  --shadow:0 18px 45px rgba(0,0,0,.55);
  --shadowSoft:0 10px 30px rgba(0,0,0,.35);
  --shadowHard:0 24px 60px rgba(0,0,0,.70);

  --radius:18px;
  --radius2:16px;
  --radius3:14px;

  --tab-height:38px;
}

html[data-theme="light"]{
  --bg:#f0f1f5;
  --bg2:#e8eaef;
  --text:rgba(0,0,0,.86);
  --muted:rgba(0,0,0,.44);

  --line:rgba(0,0,0,.07);
  --card:rgba(255,255,255,.96);

  --accent:#007aff;
  --accentSoft:rgba(0,122,255,.12);
  --accentGlow:rgba(0,122,255,.24);
  --ok:#28a745;
  --warn:#e08600;
  --err:#d93025;
  --premium:#e08600;
  --premiumGlow:rgba(224,134,0,.18);

  --shadow:0 6px 20px rgba(0,0,0,.07);
  --shadowSoft:0 4px 14px rgba(0,0,0,.05);
  --shadowHard:0 14px 36px rgba(0,0,0,.10);
}

*{box-sizing:border-box}
html,body{height:100%}

body{
  margin:0;
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","SF Pro Display",Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif;
  -webkit-font-smoothing:antialiased;
  -moz-osx-font-smoothing:grayscale;
  text-rendering:optimizeLegibility;

  background:
    radial-gradient(800px 400px at 50% -100px, rgba(46,166,255,.10), transparent 55%),
    var(--bg);
}

@supports (min-height: 100dvh){ body{ min-height:100dvh; } }

a{color:var(--accent);text-decoration:none}
a:hover{text-decoration:underline}

/* ---- page fade-in ---- */
@keyframes pageFade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:translateY(0)}}
.app{
  max-width:560px;
  margin:0 auto;
  padding:14px 14px 28px;
  animation:pageFade .25s ease both;
}

/* ---------- header ---------- */
.header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}

.brand{display:flex;align-items:center;gap:10px;min-width:0}
.brand__icon{
  width:34px;height:34px;border-radius:14px;
  display:grid;place-items:center;
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  box-shadow:var(--shadowSoft);
  transition:transform .2s ease;
}
.brand__icon:hover{transform:scale(1.06)}
.brand__text{display:flex;flex-direction:column;gap:2px;min-width:0}
.brand__title{font-weight:700;letter-spacing:.2px;font-size:15px}
.brand__subtitle{color:var(--muted);font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}

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

/* ---------- tabs ---------- */
.tabs{
  position:relative;
  padding:5px;
  border-radius:20px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.03);
  box-shadow:var(--shadow);
  display:flex;
  gap:4px;
  margin-bottom:14px;
  overflow:hidden;
}

.tabs__btn{
  flex:1 1 0;
  height:var(--tab-height);
  border:1px solid transparent;
  border-radius:13px;
  background:transparent;
  color:var(--muted);
  font-weight:600;
  font-size:13px;
  cursor:pointer;
  position:relative;
  z-index:2;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
  padding:0 6px;
  white-space:nowrap;
  transition:color .15s ease;
  letter-spacing:.1px;
}
.tabs__btn.is-active{ color:var(--text); }
.tabs__btn:hover{ color:var(--text); }

.tabs__indicator{
  position:absolute;
  left:5px;
  top:5px;
  height:var(--tab-height);
  border-radius:13px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.065);
  z-index:1;
  transition:transform .2s cubic-bezier(.4,0,.2,1),width .2s cubic-bezier(.4,0,.2,1);
  will-change:transform,width;
}

/* ---------- panel fade ---------- */
.main{min-height:220px}
.panel{display:none;opacity:0;transform:translateY(4px)}
.panel.is-active{display:block}

@keyframes panelIn{from{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}
.panel.is-active{
  animation:panelIn .2s ease both;
}

.h1{
  margin:10px 2px 12px;
  font-size:24px;
  line-height:1.15;
  letter-spacing:-.5px;
  font-weight:700;
}

/* ---------- cards ---------- */
.card{
  border-radius:var(--radius);
  border:1px solid var(--line);
  background:var(--card);
  box-shadow:var(--shadow);
  overflow:hidden;
  backdrop-filter:blur(20px);
  -webkit-backdrop-filter:blur(20px);
}
.card__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:14px 14px 8px;
}
.card__title{ font-size:16px; font-weight:600; }
.card__body{ padding:16px; }

.card__row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:0 14px 12px;
}

.card--inner{
  border-radius:var(--radius2);
  border:1px solid rgba(255,255,255,.08);
  background:rgba(255,255,255,.025);
  box-shadow:none;
}

/* ---------- tools ---------- */
.toolgrid{display:flex;flex-direction:column;gap:12px}
.toolcard{padding-bottom:10px}

.tag{
  padding:4px 10px;
  border-radius:999px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.05);
  font-weight:600;
  color:var(--muted);
  font-size:12px;
  letter-spacing:.3px;
}

.input{
  flex:1 1 auto;
  min-width:0;
  height:46px;
  padding:0 14px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(0,0,0,.14);
  color:var(--text);
  outline:none;
  font-size:15px;
  transition:border-color .18s ease,box-shadow .18s ease;
}
.input::placeholder{color:rgba(255,255,255,.28)}
.input:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px var(--accentSoft);
}

.btn{
  height:46px;
  padding:0 16px;
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.055);
  color:var(--text);
  font-weight:600;
  font-size:15px;
  cursor:pointer;
  white-space:nowrap;
  transition:transform .15s ease,box-shadow .15s ease,background .15s ease,border-color .15s ease;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
}
.btn:hover{
  border-color:rgba(255,255,255,.18);
  transform:translateY(-1px);
  box-shadow:0 4px 10px rgba(0,0,0,.2);
}
.btn:active{transform:translateY(0);box-shadow:none}
.btn:disabled{opacity:.45;cursor:not-allowed;transform:none}

.btn--primary{
  background:var(--accentSoft);
  border-color:rgba(46,166,255,.24);
  color:var(--accent);
}
.btn--primary:hover{
  border-color:rgba(46,166,255,.38);
  background:rgba(46,166,255,.22);
  box-shadow:0 4px 14px rgba(46,166,255,.18);
}

.btn--secondary{
  background:rgba(255,255,255,.04);
  border-color:rgba(255,255,255,.09);
  flex:1;
}
.btn--secondary:hover{
  background:rgba(255,255,255,.07);
  border-color:rgba(255,255,255,.16);
}

.btn--premium{
  background:linear-gradient(135deg, var(--premium) 0%, #ff9500 100%);
  border:none;
  color:#000;
  font-weight:700;
  box-shadow:0 6px 18px var(--premiumGlow);
  width:100%;
  transition:transform .15s ease,box-shadow .15s ease;
}
.btn--premium:hover{
  box-shadow:0 10px 26px var(--premiumGlow);
  transform:translateY(-2px);
}

.btn--ghost{background:rgba(255,255,255,.04)}
.btn--mini{
  height:32px;
  border-radius:12px;
  padding:0 12px;
  font-size:13px;
}

/* прогресс */
.progress{display:none;padding:0 14px 10px}
.toolcard.is-progress .progress{display:block}
.progress__bar{
  height:6px;
  border-radius:999px;
  background:var(--accent);
  width:0%;
  transition:width .2s ease;
  box-shadow:0 0 10px var(--accentGlow);
}

.result{padding:0 14px 14px}
.result__line{font-size:14px}
.muted{color:var(--muted)}
.small{font-size:13px}

/* ---------- recent ---------- */
.recentlist{display:flex;flex-direction:column;gap:10px}

.recentitem{
  border-radius:14px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(0,0,0,.10);
  padding:12px;
  display:grid;
  grid-template-columns:minmax(0,1fr) auto;
  align-items:center;
  gap:12px;
  transition:border-color .18s ease,background .18s ease,transform .15s ease;
}
.recentitem:hover{
  border-color:rgba(255,255,255,.16);
  background:rgba(0,0,0,.14);
  transform:translateY(-1px);
}
.recentitem__main{min-width:0}
.recentitem__title{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-weight:600;
  font-size:14px;
}
.recentitem__sub{
  margin-top:5px;
  display:flex;
  flex-wrap:wrap;
  gap:7px;
  align-items:center;
  font-size:12px;
}
.dot{opacity:.45}
.recentitem__actions{
  display:inline-flex;
  align-items:center;
  gap:8px;
  white-space:nowrap;
}

.pill{
  display:inline-flex;
  align-items:center;
  gap:5px;
  padding:3px 8px;
  border-radius:999px;
  font-size:11px;
  font-weight:600;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.05);
}
.pill--done{border-color:rgba(68,255,154,.18); background:rgba(68,255,154,.08); color:var(--ok)}
.pill--err{border-color:rgba(255,92,122,.20); background:rgba(255,92,122,.08); color:var(--err)}
.pill--run{border-color:rgba(46,166,255,.22); background:rgba(46,166,255,.08); color:var(--accent)}
.pill--q{border-color:rgba(255,210,77,.20); background:rgba(255,210,77,.08); color:var(--warn)}

.iconbtn{
  width:40px;height:40px;
  border-radius:13px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.05);
  color:var(--text);
  cursor:pointer;
  display:grid;
  place-items:center;
  font-size:17px;
  transition:transform .15s ease,border-color .15s ease,background .15s ease;
}
.iconbtn:hover{
  border-color:rgba(255,255,255,.18);
  transform:translateY(-1px);
  background:rgba(255,255,255,.08);
}
.iconbtn:active{transform:translateY(0)}
.iconbtn:disabled{opacity:.45;cursor:not-allowed;transform:none}
.iconbtn--danger{border-color:rgba(255,92,122,.14)}
.iconbtn--danger:hover{border-color:rgba(255,92,122,.28);background:rgba(255,92,122,.07)}
.iconbtn--header{
  width:40px;height:40px;
  font-size:17px;
}

/* ========== PROFILE ========== */
.profile{
  display:flex;
  flex-direction:column;
  gap:12px;
}

/* Hero Card */
.profile-hero{
  position:relative;
  padding:0;
  overflow:hidden;
  min-height:180px;
  display:flex;
  align-items:flex-end;
}

.profile-hero__bg{
  position:absolute;
  inset:0;
  background:
    radial-gradient(circle at 30% 20%, var(--accentGlow), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(138,92,246,.13), transparent 50%),
    linear-gradient(135deg, rgba(46,166,255,.07) 0%, rgba(138,92,246,.07) 100%);
  opacity:.75;
}

.profile-hero__content{
  position:relative;
  width:100%;
  padding:18px 20px;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:7px;
  text-align:center;
}

.profile-hero__avatar{
  width:68px;
  height:68px;
  border-radius:20px;
  background:rgba(255,255,255,.09);
  border:2px solid rgba(255,255,255,.13);
  display:grid;
  place-items:center;
  font-size:30px;
  box-shadow:0 8px 22px rgba(0,0,0,.28);
  margin-bottom:2px;
}

.profile-hero__name{
  font-size:20px;
  font-weight:700;
  letter-spacing:-.3px;
}

.profile-hero__username{
  font-size:14px;
  margin-bottom:6px;
}

.profile-hero__badge{
  padding:5px 13px;
  border-radius:999px;
  font-size:11px;
  font-weight:700;
  letter-spacing:.6px;
  background:rgba(46,166,255,.16);
  border:1px solid rgba(46,166,255,.28);
  color:var(--accent);
  box-shadow:0 3px 10px rgba(46,166,255,.20);
}

.profile-hero__badge.is-premium{
  background:linear-gradient(135deg, var(--premium), #ff9500);
  border:1px solid rgba(255,184,0,.35);
  color:#000;
  box-shadow:0 5px 14px var(--premiumGlow);
}

/* Usage Card */
.usage-card{ padding:16px; }

.usage-card__header{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:14px;
}

.usage-card__icon{
  width:34px;height:34px;
  border-radius:11px;
  background:var(--accentSoft);
  display:grid;
  place-items:center;
  font-size:17px;
}

.usage-card__title{ font-size:16px; font-weight:600; }

.usage-stats__main{
  text-align:center;
  margin-bottom:16px;
}

.usage-stats__value{
  font-size:40px;
  font-weight:700;
  letter-spacing:-1px;
  line-height:1;
  margin-bottom:5px;
}

.usage-stats__divider{ color:var(--muted); margin:0 3px; }

.usage-stats__label{ font-size:13px; }

.usage-progress{ margin-bottom:16px; }

.usage-progress__track{
  height:10px;
  border-radius:999px;
  background:rgba(255,255,255,.07);
  overflow:hidden;
  margin-bottom:7px;
  border:1px solid rgba(255,255,255,.09);
}

.usage-progress__fill{
  height:100%;
  width:0%;
  background:linear-gradient(90deg, var(--accent), rgba(46,166,255,.7));
  border-radius:999px;
  transition:width .4s cubic-bezier(.4,0,.2,1);
  box-shadow:0 0 10px var(--accentGlow);
}

.usage-progress__label{
  display:flex;
  justify-content:space-between;
  font-size:12px;
  color:var(--muted);
}

.usage-progress__count{ font-weight:600; color:var(--text); }

/* Premium Card */
.premium-card{
  position:relative;
  padding:18px;
  background:linear-gradient(135deg, rgba(255,184,0,.10), rgba(255,149,0,.07));
  border-color:rgba(255,184,0,.22);
  overflow:hidden;
}

.premium-card__glow{
  position:absolute;
  inset:0;
  background:
    radial-gradient(circle at 20% 30%, var(--premiumGlow), transparent 60%),
    radial-gradient(circle at 80% 70%, rgba(255,149,0,.12), transparent 60%);
  animation:premiumPulse 4s ease-in-out infinite;
}

@keyframes premiumPulse{0%,100%{opacity:.45}50%{opacity:.75}}

.premium-card__content{ position:relative; text-align:center; }

.premium-card__icon{ font-size:30px; margin-bottom:6px; }

.premium-card__title{
  font-size:19px;
  font-weight:700;
  margin-bottom:5px;
  background:linear-gradient(135deg, var(--premium), #ff9500);
  -webkit-background-clip:text;
  -webkit-text-fill-color:transparent;
  background-clip:text;
}

.premium-card__until{
  font-size:13px;
  display:flex;
  justify-content:center;
  gap:5px;
}

/* Referrals Card */
.refs-card{ padding:16px; }

.refs-card__header{
  display:flex;
  align-items:flex-start;
  gap:11px;
  margin-bottom:14px;
}

.refs-card__icon{
  width:38px;height:38px;
  border-radius:12px;
  background:linear-gradient(135deg, rgba(138,92,246,.14), rgba(99,102,241,.10));
  display:grid;
  place-items:center;
  font-size:18px;
  flex-shrink:0;
}

.refs-card__title{ font-size:16px; font-weight:600; margin-bottom:2px; }
.refs-card__subtitle{ font-size:13px; }

.refs-stats{
  display:flex;
  gap:10px;
  margin-bottom:14px;
}

.refs-stat{
  flex:1;
  padding:12px;
  border-radius:13px;
  background:rgba(255,255,255,.035);
  border:1px solid rgba(255,255,255,.09);
  text-align:center;
}

.refs-stat__value{
  font-size:26px;
  font-weight:700;
  margin-bottom:3px;
  color:var(--accent);
}

.refs-stat__label{ font-size:11px; }

.refs-link{
  margin-bottom:11px;
  padding:11px 12px;
  border-radius:12px;
  background:rgba(0,0,0,.18);
  border:1px solid rgba(255,255,255,.09);
}

.refs-link__text{
  font-size:13px;
  font-family:ui-monospace,SFMono-Regular,Monaco,Consolas,monospace;
  color:var(--accent);
  word-break:break-all;
  line-height:1.5;
}

.refs-actions{ display:flex; gap:8px; }

/* Settings Card */
.settings-card{ padding:16px; }
.settings-card__title{ font-size:16px; font-weight:600; margin-bottom:11px; }

.setting-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:11px 0;
  border-bottom:1px solid rgba(255,255,255,.055);
}
.setting-row:last-child{ border-bottom:none; }

.setting-row__label{
  display:flex;
  align-items:center;
  gap:10px;
  font-size:15px;
  font-weight:500;
}
.setting-row__icon{ font-size:17px; }

/* segmented mini */
.segmini{
  position:relative;
  display:inline-flex;
  align-items:center;
  gap:3px;
  padding:4px;
  border-radius:11px;
  background:rgba(255,255,255,.055);
  border:1px solid rgba(255,255,255,.09);
}

.segmini__btn{
  height:30px;
  min-width:46px;
  padding:0 12px;
  border-radius:9px;
  border:none;
  background:transparent;
  color:var(--muted);
  cursor:pointer;
  font-weight:600;
  font-size:13px;
  position:relative;
  z-index:2;
  white-space:nowrap;
  transition:color .15s ease;
}
.segmini__btn.is-active{ color:var(--text); }
.segmini__btn:hover{ color:var(--text); }

.segmini__indicator{
  position:absolute;
  left:4px;top:4px;
  height:30px;
  border-radius:9px;
  background:var(--accentSoft);
  border:1px solid rgba(46,166,255,.18);
  z-index:1;
  transition:transform .2s cubic-bezier(.4,0,.2,1),width .2s cubic-bezier(.4,0,.2,1);
  box-shadow:0 2px 7px rgba(46,166,255,.12);
}

/* ========== HELP ========== */
.help-page{
  display:flex;
  flex-direction:column;
  gap:12px;
}

.help-section{
  padding:16px;
}

.help-section__title{
  font-size:15px;
  font-weight:700;
  margin-bottom:12px;
  display:flex;
  align-items:center;
  gap:8px;
}

.help-section__title-icon{
  font-size:17px;
}

.help-list{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  flex-direction:column;
  gap:8px;
}

.help-list li{
  display:flex;
  align-items:flex-start;
  gap:10px;
  font-size:14px;
  line-height:1.5;
  color:var(--muted);
}

.help-list li::before{
  content:'';
  display:block;
  width:5px;
  height:5px;
  border-radius:50%;
  background:var(--accent);
  margin-top:7px;
  flex-shrink:0;
}

.help-feature-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:8px;
}

.help-feature{
  padding:12px;
  border-radius:13px;
  background:rgba(255,255,255,.03);
  border:1px solid rgba(255,255,255,.08);
}

.help-feature__icon{
  font-size:20px;
  margin-bottom:6px;
}

.help-feature__title{
  font-size:13px;
  font-weight:600;
  margin-bottom:3px;
}

.help-feature__desc{
  font-size:12px;
  color:var(--muted);
  line-height:1.4;
}

.help-premium-list{
  list-style:none;
  margin:0;
  padding:0;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.help-premium-list li{
  display:flex;
  align-items:center;
  gap:10px;
  font-size:14px;
  line-height:1.45;
}

.help-premium-list li::before{
  content:'✓';
  color:var(--premium);
  font-weight:700;
  font-size:14px;
  flex-shrink:0;
}

.help-ref-steps{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.help-ref-step{
  display:flex;
  align-items:flex-start;
  gap:12px;
}

.help-ref-step__num{
  width:24px;height:24px;
  border-radius:50%;
  background:var(--accentSoft);
  border:1px solid rgba(46,166,255,.24);
  color:var(--accent);
  font-size:12px;
  font-weight:700;
  display:grid;
  place-items:center;
  flex-shrink:0;
}

.help-ref-step__text{
  font-size:14px;
  color:var(--muted);
  line-height:1.5;
  padding-top:2px;
}

.help-privacy-note{
  display:flex;
  align-items:flex-start;
  gap:10px;
  padding:12px;
  border-radius:12px;
  background:rgba(68,255,154,.08);
  border:1px solid rgba(68,255,154,.20);
  margin-bottom:12px;
  font-size:13px;
  line-height:1.5;
  color:var(--text);
}

.help-privacy-note__icon{
  font-size:16px;
  flex-shrink:0;
  margin-top:1px;
}

.help-btn-privacy{
  width:100%;
  justify-content:center;
}

.help-divider{
  height:1px;
  background:var(--line);
  margin:4px 0;
}

/* ---------- toast ---------- */
.toast{
  position:fixed;
  left:50%;
  bottom:24px;
  transform:translateX(-50%) translateY(12px);
  width:auto;
  max-width:min(400px, calc(100vw - 28px));
  border-radius:15px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(14,15,18,.75);
  backdrop-filter:blur(22px);
  -webkit-backdrop-filter:blur(22px);
  box-shadow:var(--shadowHard);
  padding:11px 15px;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s ease,transform .2s cubic-bezier(.34,1.56,.64,1);
  z-index:9999;
}
.toast.is-on{
  opacity:1;
  transform:translateX(-50%) translateY(0);
  pointer-events:auto;
}
.toast__inner{display:inline-flex;align-items:center;gap:9px}
.toast__icon{flex:0 0 auto;font-size:18px}
.toast__msg{
  flex:1 1 auto;
  min-width:0;
  font-weight:600;
  white-space:normal;
  font-size:14px;
}

/* ---------- focus ---------- */
.tabs__btn,
.segmini__btn,
.btn,
.iconbtn{
  -webkit-tap-highlight-color:transparent;
}
.tabs__btn:focus,
.segmini__btn:focus,
.btn:focus,
.iconbtn:focus{outline:none}
.tabs__btn:focus-visible,
.segmini__btn:focus-visible,
.btn:focus-visible,
.iconbtn:focus-visible{
  outline:2px solid var(--accent);
  outline-offset:2px;
}

/* ---------- light theme ---------- */
html[data-theme="light"] body{
  background:
    radial-gradient(700px 350px at 50% -80px, rgba(0,122,255,.07), transparent 55%),
    var(--bg);
}

html[data-theme="light"] .tabs{
  background:rgba(255,255,255,.82);
  backdrop-filter:blur(20px);
  border-color:rgba(0,0,0,.07);
}
html[data-theme="light"] .tabs__indicator{
  border-color:rgba(0,0,0,.07);
  background:rgba(0,0,0,.048);
}
html[data-theme="light"] .tabs__btn{color:rgba(0,0,0,.46)}
html[data-theme="light"] .tabs__btn.is-active{color:rgba(0,0,0,.86)}

html[data-theme="light"] .card{
  background:rgba(255,255,255,.94);
  border-color:rgba(0,0,0,.07);
  box-shadow:0 4px 18px rgba(0,0,0,.06);
}
html[data-theme="light"] .card--inner{
  background:rgba(0,0,0,.025);
  border-color:rgba(0,0,0,.07);
}

html[data-theme="light"] .btn{
  border-color:rgba(0,0,0,.09);
  background:rgba(255,255,255,.90);
  color:rgba(0,0,0,.86);
  box-shadow:0 1px 4px rgba(0,0,0,.06);
}
html[data-theme="light"] .btn--primary{
  background:rgba(0,122,255,.11);
  border-color:rgba(0,122,255,.20);
  color:var(--accent);
}
html[data-theme="light"] .btn--secondary{
  background:rgba(0,0,0,.04);
  border-color:rgba(0,0,0,.09);
}
html[data-theme="light"] .btn--premium{
  background:linear-gradient(135deg, #f5a000 0%, #e07800 100%);
  color:#fff;
  box-shadow:0 5px 18px rgba(224,134,0,.32);
}
html[data-theme="light"] .btn--premium:hover{
  box-shadow:0 8px 24px rgba(224,134,0,.40);
}

html[data-theme="light"] .input{
  background:rgba(255,255,255,.92);
  border-color:rgba(0,0,0,.11);
  color:rgba(0,0,0,.86);
  box-shadow:0 1px 3px rgba(0,0,0,.05);
}
html[data-theme="light"] .input::placeholder{color:rgba(0,0,0,.32)}

html[data-theme="light"] .segmini{
  background:rgba(255,255,255,.88);
  border-color:rgba(0,0,0,.09);
}
html[data-theme="light"] .segmini__btn{color:rgba(0,0,0,.46)}
html[data-theme="light"] .segmini__btn.is-active{color:rgba(0,0,0,.86)}
html[data-theme="light"] .segmini__indicator{
  border-color:rgba(0,122,255,.18);
  background:rgba(0,122,255,.10);
}

html[data-theme="light"] .recentitem{
  background:rgba(255,255,255,.88);
  border-color:rgba(0,0,0,.09);
}
html[data-theme="light"] .recentitem:hover{
  background:rgba(255,255,255,.96);
  border-color:rgba(0,0,0,.13);
}

html[data-theme="light"] .refs-stat{
  background:rgba(0,0,0,.03);
  border-color:rgba(0,0,0,.08);
}

html[data-theme="light"] .refs-link{
  background:rgba(0,0,0,.04);
  border-color:rgba(0,0,0,.08);
}

html[data-theme="light"] .iconbtn{
  border-color:rgba(0,0,0,.09);
  background:rgba(255,255,255,.80);
}
html[data-theme="light"] .iconbtn:hover{
  background:rgba(255,255,255,.96);
  border-color:rgba(0,0,0,.13);
}

html[data-theme="light"] .profile-hero__bg{
  background:
    radial-gradient(circle at 30% 20%, rgba(0,122,255,.16), transparent 50%),
    radial-gradient(circle at 70% 80%, rgba(138,92,246,.10), transparent 50%),
    linear-gradient(135deg, rgba(0,122,255,.07) 0%, rgba(138,92,246,.05) 100%);
}

html[data-theme="light"] .tag{
  border-color:rgba(0,0,0,.09);
  background:rgba(0,0,0,.05);
  color:rgba(0,0,0,.55);
}

html[data-theme="light"] .help-feature{
  background:rgba(0,0,0,.03);
  border-color:rgba(0,0,0,.08);
}

html[data-theme="light"] .help-privacy-note{
  background:rgba(40,167,69,.07);
  border-color:rgba(40,167,69,.20);
  color:var(--text);
}

html[data-theme="light"] .toast{
  background:rgba(255,255,255,.92);
  border-color:rgba(0,0,0,.09);
  color:rgba(0,0,0,.86);
  box-shadow:0 10px 30px rgba(0,0,0,.12);
}

/* ========== MODAL (Settings bottom sheet) ========== */
body.modal-open{ overflow:hidden; }

.modal{
  position:fixed;
  inset:0;
  z-index:9000;
  display:none;
}
.modal.is-open{ display:block; }

.modal__backdrop{
  position:absolute;
  inset:0;
  background:rgba(0,0,0,.50);
  backdrop-filter:blur(16px);
  -webkit-backdrop-filter:blur(16px);
  animation:backdropIn .2s ease both;
}

@keyframes backdropIn{from{opacity:0}to{opacity:1}}

/* Bottom sheet on ALL screens */
.modal__sheet{
  position:absolute;
  left:0;
  right:0;
  bottom:0;
  width:100%;
  max-height:80vh;
  border-radius:22px 22px 0 0;
  border:1px solid var(--line);
  border-bottom:none;
  background:rgba(20,21,26,.95);
  box-shadow:0 -12px 40px rgba(0,0,0,.45);
  overflow:hidden;
  backdrop-filter:blur(24px);
  -webkit-backdrop-filter:blur(24px);
  animation:sheetUp .25s cubic-bezier(.34,1.2,.64,1) both;
}

@keyframes sheetUp{
  from{transform:translateY(100%)}
  to{transform:translateY(0)}
}

/* On wider screens — cap the width and center it */
@media (min-width:521px){
  .modal__sheet{
    left:50%;
    right:auto;
    bottom:0;
    width:min(520px, calc(100vw - 28px));
    transform:translateX(-50%);
    border-radius:22px 22px 0 0;
    animation:sheetUpCenter .25s cubic-bezier(.34,1.2,.64,1) both;
  }
  @keyframes sheetUpCenter{
    from{transform:translateX(-50%) translateY(100%)}
    to{transform:translateX(-50%) translateY(0)}
  }
}

/* drag handle */
.modal__handle{
  width:36px;height:4px;
  border-radius:999px;
  background:rgba(255,255,255,.18);
  margin:10px auto 0;
  flex-shrink:0;
}

.modal__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:10px 14px 10px;
  border-bottom:1px solid var(--line);
  background:rgba(255,255,255,.02);
}

.modal__title{
  font-size:16px;
  font-weight:700;
  letter-spacing:-.2px;
}

.modal__body{
  padding:12px;
  overflow-y:auto;
  max-height:calc(80vh - 60px);
  -webkit-overflow-scrolling:touch;
}

.modal__card{ padding:13px; }

.modal__links{
  margin-top:10px;
  border-radius:var(--radius);
  border:1px solid var(--line);
  background:var(--card);
  overflow:hidden;
}

.modal__link{
  width:100%;
  display:flex;
  align-items:center;
  gap:12px;
  padding:13px 14px;
  background:transparent;
  border:none;
  color:var(--text);
  cursor:pointer;
  border-bottom:1px solid var(--line);
  transition:background .18s ease,transform .15s ease;
}
.modal__link:last-child{ border-bottom:none; }
.modal__link:hover{
  background:rgba(255,255,255,.04);
  transform:translateX(2px);
}
.modal__link:active{ transform:translateX(0); }

.modal__linkIcon{
  width:36px;height:36px;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
  background:rgba(255,255,255,.055);
  display:grid;
  place-items:center;
  font-size:17px;
  flex:0 0 auto;
}

.modal__linkText{
  flex:1 1 auto;
  text-align:left;
  font-size:15px;
  font-weight:600;
}

.modal__chev{
  color:var(--muted);
  font-size:20px;
  line-height:1;
}

/* light theme modal */
html[data-theme="light"] .modal__backdrop{
  background:rgba(0,0,0,.26);
}
html[data-theme="light"] .modal__sheet{
  background:rgba(246,247,251,.97);
  border-color:rgba(0,0,0,.09);
  box-shadow:0 -8px 32px rgba(0,0,0,.12);
}
html[data-theme="light"] .modal__head{
  background:rgba(255,255,255,.75);
  border-bottom-color:rgba(0,0,0,.08);
}
html[data-theme="light"] .modal__handle{
  background:rgba(0,0,0,.14);
}
html[data-theme="light"] .modal__links{
  border-color:rgba(0,0,0,.09);
  background:rgba(255,255,255,.90);
}
html[data-theme="light"] .modal__link{
  border-bottom-color:rgba(0,0,0,.07);
}
html[data-theme="light"] .modal__link:hover{
  background:rgba(0,0,0,.03);
}
html[data-theme="light"] .modal__linkIcon{
  border-color:rgba(0,0,0,.09);
  background:rgba(0,0,0,.04);
}

/* ========== MOBILE ========== */
@media (max-width:640px){
  .app{
    padding:10px 12px calc(16px + env(safe-area-inset-bottom));
  }
  .header{
    padding:8px 0;
  }
  .h1{
    font-size:21px;
    margin:8px 2px 10px;
  }
  .card__row{
    flex-direction:column;
    gap:9px;
  }
  .input, .btn{
    width:100%;
    height:46px;
    border-radius:14px;
  }
  .toolgrid{ gap:10px; }
  .help-feature-grid{ grid-template-columns:1fr 1fr; gap:7px; }
}

/* ========== HEADER AVATAR ========== */
.header__avatar{
  width:24px;height:24px;
  border-radius:50%;
  display:grid;
  place-items:center;
  overflow:hidden;
  font-size:15px;
}
.header__avatar.has-photo{
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
  font-size:0;
}
.profile-hero__avatar.has-photo{
  background-size:cover;
  background-position:center;
  background-repeat:no-repeat;
  font-size:0;
}

.brand__logo {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 6px;
  display: block;
}