/* ═══════════════════════════════════════════════════════
   Uchiha Ultralock — Web (PWA)
   Faithful re-creation of the iOS app (red-black Uchiha theme)
   ═══════════════════════════════════════════════════════ */

:root {
  --bg-start: #050000;
  --bg-end: #1A0000;
  --card-bg: #1A0000;
  --card-border: rgba(74, 0, 0, 0.5);
  --glow: #FF0000;
  --deep: #8A0000;
  --deeper: #330000;
  --ring: #CC4444;
  --text-primary: #FFFFFF;
  --text-secondary: #D99B9B;
  --toggle-on: #FF0000;
  --toggle-off: #4A0000;
  --tier-basic: #AA3333;
  --tier-pro: #CC4444;
  --tier-vip: #FF0000;
  --danger: #FF0000;
  --danger-bg: #CC0000;
  --success: #00CC66;
  --warning: #FFAA00;
  --gauge-empty: #4A0000;
  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-start);
  font-family: var(--font-ui);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app { position: fixed; inset: 0; }

.hidden { display: none !important; }

/* ══════════ ICONS ══════════ */
.ic { display: inline-flex; align-items: center; justify-content: center; }
.ic svg { width: 100%; height: 100%; fill: currentColor; display: block; }
.ic.stroke svg { fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ══════════ BACKGROUND ══════════ */
.bg-gradient {
  position: absolute; inset: 0;
  background: linear-gradient(to bottom right, var(--bg-start), var(--bg-end));
}
.bg-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(to right, rgba(74, 0, 0, 0.3) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(74, 0, 0, 0.3) 1px, transparent 1px);
  background-size: 32px 32px;
  pointer-events: none;
}

/* ══════════ SCREEN ROOT ══════════ */
.screen {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-start);
}

/* ══════════ CARD ══════════ */
.card {
  background: var(--card-bg);
  border-radius: 14px;
  border: 1px solid var(--card-border);
  padding: 14px;
}

.divider { height: 1px; background: var(--card-border); margin: 2px 0; }

/* ══════════ TOAST ══════════ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 100px);
  transform: translateX(-50%) translateY(20px);
  padding: 10px 20px;
  border-radius: 999px;
  background: var(--glow);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  box-shadow: 0 0 12px rgba(255, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 999;
  max-width: 86vw;
  text-align: center;
}
.toast.error { background: var(--danger-bg); box-shadow: 0 0 12px rgba(204, 0, 0, 0.45); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ══════════ LOGIN ══════════ */
#screen-login { overflow: hidden; }
.login-scroll { position: absolute; inset: 0; overflow-y: auto; }
.login-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 24px 40px;
  gap: 20px;
}
.login-avatar {
  width: 110px; height: 110px;
  margin-top: 20px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--glow);
  box-shadow: 0 0 16px rgba(255, 0, 0, 0.4);
}
.login-title {
  font-size: 28px;
  font-weight: 700;
  font-style: italic;
  color: var(--text-primary);
  text-align: center;
}
.login-subtitle {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}
.login-card {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-inner > .card { width: 100%; }
.login-card-title {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--glow);
}
.login-card-sub {
  font-size: 11px;
  color: var(--text-secondary);
}
.key-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  background: rgba(5, 0, 0, 0.5);
  border-radius: 8px;
  border: 1px solid var(--card-border);
}
.key-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  padding: 10px 0;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  min-width: 0;
}
.key-input::placeholder { color: rgba(217, 155, 155, 0.55); }
.eye-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.eye-btn .ic { width: 14px; height: 14px; }

.copyable-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.row-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}
.row-value {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  margin-left: auto;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.copy-btn {
  background: none;
  border: none;
  color: var(--glow);
  width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex: none;
}
.copy-btn .ic { width: 12px; height: 12px; }
.hwid-row .row-label { text-transform: uppercase; }

.login-error {
  min-height: 20px;
  font-size: 12px;
  color: var(--danger);
  text-align: center;
  width: 100%;
}

.activate-btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(to right, var(--glow), var(--deep));
  box-shadow: inset 0 0 0 1px rgba(255, 0, 0, 0.5);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  transition: opacity .2s ease;
}
.activate-btn:disabled { opacity: 0.5; cursor: default; }
.activate-btn:active:not(:disabled) { filter: brightness(1.1); }
.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.35);
  border-top-color: #fff;
  animation: spin .7s linear infinite;
  flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.guide-title {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  color: var(--glow);
  margin-bottom: 8px;
}
.guide-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.guide-num {
  font-size: 10px;
  font-weight: 700;
  color: var(--glow);
  width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 0, 0, 0.15);
  border-radius: 50%;
  flex: none;
}
.guide-text { font-size: 11px; color: var(--text-secondary); }

.admin-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 6px;
}
.admin-head-icon {
  width: 26px; height: 26px;
  color: var(--glow);
  background: rgba(255, 0, 0, 0.12);
  border-radius: 50%;
}
.admin-head-icon .ic { width: 12px; height: 12px; }
.admin-head-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--glow);
}
.admin-head-info { display: flex; flex-direction: column; gap: 2px; }
.admin-head-sub { font-size: 10px; color: var(--text-secondary); }

.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
}
.admin-row.big { padding: 8px 0; }
.admin-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(to bottom right, var(--deep), var(--deeper));
  border: 1.5px solid var(--ring);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  flex: none;
}
.admin-row.big .admin-avatar { width: 40px; height: 40px; font-size: 14px; }
.admin-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.admin-name { font-size: 12px; font-weight: 600; color: var(--text-primary); }
.admin-phone {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ring);
}
.admin-role { font-size: 10px; color: var(--text-secondary); }
.admin-copy {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--glow);
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex: none;
  border-radius: 50%;
  background: rgba(255, 0, 0, 0.12);
}
.admin-copy .ic { width: 10px; height: 10px; }

.contact-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
}
.contact-icon { width: 14px; height: 14px; color: var(--glow); flex: none; }
.contact-label { font-size: 11px; font-weight: 500; color: var(--text-secondary); }
.contact-value {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  white-space: nowrap;
}
.copy-cap {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  color: var(--glow);
  padding: 3px 6px;
  background: rgba(255, 0, 0, 0.12);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  flex: none;
}

/* ══════════ TOP BAR ══════════ */
.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(var(--safe-top) + 10px) 18px 10px;
  background: rgba(26, 0, 0, 0.85);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  z-index: 5;
}
.topbar-avatar {
  width: 22px; height: 22px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--glow);
  flex: none;
}
.topbar-title {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.fps-counter {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ══════════ TIER BADGE ══════════ */
.tier-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.tier-badge.basic { color: var(--tier-basic); background: rgba(170,51,51,.15); box-shadow: inset 0 0 0 1px rgba(170,51,51,.4); }
.tier-badge.pro   { color: var(--tier-pro);   background: rgba(204,68,68,.15); box-shadow: inset 0 0 0 1px rgba(204,68,68,.4); }
.tier-badge.vip   { color: var(--tier-vip);   background: rgba(255,0,0,.15);   box-shadow: inset 0 0 0 1px rgba(255,0,0,.4); }

/* ══════════ PAGES / SWIPE ══════════ */
.pages {
  flex: 1;
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.pages::-webkit-scrollbar { display: none; }
.page {
  flex: 0 0 100%;
  width: 100%;
  scroll-snap-align: start;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.page::-webkit-scrollbar { display: none; }
.page-inner {
  padding: 8px 18px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ══════════ SECTION HEADER ══════════ */
.section-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-top: 8px;
  padding-bottom: 4px;
}
.section-header .ic { width: 12px; height: 12px; color: var(--glow); }
.section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ══════════ STATUS CARD ══════════ */
.status-card { display: flex; align-items: center; gap: 18px; }
.status-left { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.status-title-row { display: flex; align-items: center; gap: 6px; }
.status-title-row .ic { width: 13px; height: 13px; }
.status-title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 0 2px rgba(255, 0, 0, 0.3);
}
.status-key-row { display: flex; align-items: center; gap: 4px; }
.status-key-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.status-key-value {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 999px;
}
.status-active-row { display: flex; align-items: center; gap: 4px; }
.status-active-label { font-size: 11px; font-weight: 600; color: var(--text-secondary); }
.status-active-value {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}
.status-progress {
  height: 6px;
  border-radius: 2px;
  background: var(--card-border);
  overflow: hidden;
}
.status-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width .4s ease;
  box-shadow: 0 0 3px rgba(255, 0, 0, 0.4);
}
.status-state-row { display: flex; align-items: center; gap: 4px; }
.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  box-shadow: 0 0 3px rgba(0, 204, 102, 0.5);
}
.status-state {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
}

.clock { position: relative; width: 110px; height: 110px; flex: none; }
.clock svg { width: 100%; height: 100%; }
.clock-center {
  position: absolute; inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
}
.clock-time {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}
.clock-lv {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  border-radius: 999px;
}
.clock-lv-label { font-family: var(--font-mono); font-size: 8px; font-weight: 600; color: var(--text-secondary); }
.clock-lv-value { font-family: var(--font-mono); font-size: 10px; font-weight: 700; }

/* ══════════ TOGGLE ROW ══════════ */
.toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}
.toggle-row .feat-icon { width: 22px; height: 22px; flex: none; color: var(--text-secondary); }
.toggle-row.on .feat-icon { color: var(--glow); }
.feat-title {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 0;
}
.toggle-row.on .feat-title { color: var(--text-primary); }
.toggle-row .feat-extra { flex: none; display: flex; align-items: center; gap: 8px; }
.toggle-row .feat-extra .ic { width: 12px; height: 12px; }
.toggle-row .feat-extra .lock-ic { color: var(--text-secondary); }
.toggle-row .feat-extra .crown-ic { color: var(--tier-vip); }

/* iOS-like switch */
.switch {
  position: relative;
  flex: none;
  width: 40px; height: 24px;
  transform: scale(0.8);
}
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch .track {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: var(--toggle-off);
  transition: background .2s ease;
}
.switch .thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.35);
  transition: transform .2s ease;
}
.switch input:checked + .track { background: var(--toggle-on); }
.switch input:checked + .track + .thumb { transform: translateX(16px); }
.switch.disabled { opacity: 0.5; }
.switch.disabled input { cursor: not-allowed; }

/* ══════════ LOCK (tuner) ══════════ */
.tuner-locked {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 200px;
  margin-top: 8px;
  background: rgba(11, 8, 8, 0.5);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-radius: 14px;
  border: 1px solid var(--card-border);
}
.lock-icon { width: 20px; height: 20px; color: var(--text-secondary); }
.lock-text { font-size: 12px; font-weight: 500; color: var(--text-secondary); }

/* ══════════ ADVANCED TUNER ══════════ */
.tuner-row { padding: 12px 0 4px; }
.tuner-row + .tuner-row { padding-top: 16px; }
.tuner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}
.tuner-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.tuner-value { font-family: var(--font-mono); font-size: 13px; font-weight: 700; }
.tuner-value.glow { color: var(--glow); }
.tuner-value.vip { color: var(--tier-vip); }
input[type=range].tuner-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(to right, var(--glow) var(--fill,50%), var(--toggle-off) var(--fill,50%));
  outline: none;
}
input[type=range].tuner-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,.4);
  cursor: pointer;
}
input[type=range].tuner-slider.recoil { background: linear-gradient(to right, var(--tier-vip) var(--fill,50%), var(--toggle-off) var(--fill,50%)); }

.seg-row { display: flex; gap: 8px; padding-top: 6px; }
.seg-btn {
  flex: 1;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 8px 0;
  background: rgba(5, 0, 0, 0.5);
  border: 1px solid var(--card-border);
  border-radius: 999px;
  cursor: pointer;
  text-align: center;
}
.seg-btn.active {
  color: #fff;
  background: var(--glow);
  border-color: var(--glow);
}

/* ══════════ USER PAGE ══════════ */
.user-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding-top: 10px;
}
.user-avatar {
  width: 80px; height: 80px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--glow);
  box-shadow: 0 0 10px rgba(255, 0, 0, 0.3);
}
.user-tier-title {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
}

.member-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}
.member-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 0 0 130px;
}
.member-value {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-primary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
}
.member-copy {
  background: none;
  border: none;
  color: var(--glow);
  width: 18px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  flex: none;
}
.member-copy .ic { width: 10px; height: 10px; }

.logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px;
  background: rgba(255, 0, 0, 0.1);
  border: 1px solid rgba(255, 0, 0, 0.3);
  border-radius: 10px;
  color: var(--danger);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.logout-btn .ic { width: 14px; height: 14px; }
.logout-btn:active { background: rgba(255, 0, 0, 0.2); }

.app-info { display: flex; flex-direction: column; align-items: center; gap: 4px; padding-top: 8px; }
.app-info-name { font-size: 12px; font-weight: 600; color: var(--text-secondary); }
.app-info-version { font-size: 10px; color: rgba(217, 155, 155, 0.6); }

/* ══════════ SYSTEM INFO ══════════ */
.storage-bar {
  margin-top: 8px;
  height: 5px;
  border-radius: 999px;
  background: var(--gauge-empty);
  overflow: hidden;
}
.storage-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--glow);
  transition: width .4s ease;
}
.storage-fill.danger { background: var(--danger); }

.info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 0;
}

/* ══════════ TAB BAR ══════════ */
.tabbar {
  flex: none;
  display: flex;
  background: rgba(26, 0, 0, 0.95);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  border-top: 0.5px solid var(--card-border);
  padding-bottom: var(--safe-bottom);
  z-index: 5;
}
.tab-btn {
  flex: 1;
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 0;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color .2s ease;
}
.tab-btn .tab-icon { width: 18px; height: 18px; }
.tab-btn .tab-label { font-size: 9px; font-weight: 400; }
.tab-btn.active { color: var(--glow); }
.tab-btn.active .tab-icon { font-weight: 600; }
.tab-btn.active .tab-label { font-weight: 600; }

.bottom-spacer { height: 60px; flex: none; }

/* scrollbar hiding for inner pages on desktop */
body { scrollbar-width: none; }
