/* ─── Reset & Base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #000;
  --surface: rgba(255,255,255,0.08);
  --surface2: rgba(255,255,255,0.13);
  --text: #fff;
  --text2: rgba(255,255,255,0.65);
  --accent: #4fc3f7;
  --accent2: #0288d1;
  --danger: #f44336;
  --success: #4caf50;
  --radius: 14px;
  --font: 'Roboto', 'Segoe UI', system-ui, sans-serif;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: linear-gradient(135deg,#0f0c29,#302b63,#24243e);
  color: var(--text);
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ─── Phone Frame ───────────────────────────────────────────── */
#phone-frame {
  position: relative;
  width: 100%;
  max-width: 390px;
  height: 100vh;
  max-height: 844px;
  margin: 0 auto;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  box-shadow: 0 0 60px rgba(0,0,0,.9);
}

/* ─── Status Bar ────────────────────────────────────────────── */
#status-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  height: 28px;
  padding: 0 14px;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(10px);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  z-index: 100;
}
.status-left { display:flex; align-items:center; gap:6px; }
.status-right { display:flex; align-items:center; gap:6px; }
.status-icons { display:flex; gap:4px; font-size:12px; }
#notif-badge {
  background: var(--danger);
  color: #fff;
  border-radius: 10px;
  padding: 0 5px;
  font-size: 9px;
  min-width: 16px;
  text-align: center;
  cursor: pointer;
}

/* ─── Screen Area ───────────────────────────────────────────── */
#screen {
  flex: 1;
  position: relative;
  overflow: hidden;
}

/* ─── Boot Screen ───────────────────────────────────────────── */
#boot {
  position: absolute;
  inset: 0;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  transition: opacity .5s;
}
.boot-logo { font-size: 3.5rem; margin-bottom: 16px; animation: pulse 1s infinite; }
.boot-title { font-size: 1.8rem; font-weight: 700; letter-spacing: 2px; color: #4fc3f7; }
.boot-sub { font-size: .85rem; opacity: .6; margin-top: 4px; }
.boot-loader {
  width: 160px; height: 3px; background: rgba(255,255,255,.15);
  border-radius: 3px; margin-top: 32px; overflow: hidden;
}
.boot-loader-bar {
  height: 100%; width: 0; background: #4fc3f7;
  animation: bootLoad 1.6s ease-in-out forwards;
}
@keyframes bootLoad { to { width: 100%; } }
@keyframes pulse { 0%,100%{transform:scale(1)} 50%{transform:scale(1.1)} }

/* ─── Lock Screen ───────────────────────────────────────────── */
#lockscreen {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.5);
  backdrop-filter: blur(20px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 900;
  cursor: pointer;
  transition: transform .4s ease, opacity .4s ease;
}
.lock-time {
  font-size: 4.5rem;
  font-weight: 200;
  letter-spacing: -2px;
  line-height: 1;
}
.lock-date {
  font-size: .95rem;
  opacity: .7;
  margin-top: 8px;
  text-transform: capitalize;
}
.lock-hint {
  font-size: .8rem;
  opacity: .5;
  margin-top: 40px;
  animation: bounce 2s infinite;
}
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)} }
.lock-notifs { margin-top: 24px; width: 90%; }

/* ─── Home Screen ───────────────────────────────────────────── */
#homescreen {
  position: absolute;
  inset: 0;
  display: none;
  padding: 12px 8px 0;
  overflow-y: auto;
}
.app-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding-bottom: 100px;
}
.app-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 8px 4px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.app-icon:active { transform: scale(.9); background: rgba(255,255,255,.1); }
.app-icon-img {
  width: 56px; height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 4px 12px rgba(0,0,0,.4);
}
.app-icon-label {
  font-size: .65rem;
  text-align: center;
  opacity: .9;
  line-height: 1.2;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Dock ──────────────────────────────────────────────────── */
.dock {
  position: fixed;
  bottom: 56px;
  left: 50%; transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 360px;
  display: flex;
  justify-content: space-around;
  background: rgba(255,255,255,.12);
  backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.15);
}
.dock-icon {
  font-size: 1.7rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 12px;
  transition: transform .15s;
}
.dock-icon:active { transform: scale(.85); }

/* ─── Navigation Bar ────────────────────────────────────────── */
#nav-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  height: 48px;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.nav-btn {
  background: none; border: none; color: var(--text);
  font-size: 1.2rem; padding: 6px 10px; cursor: pointer;
  border-radius: 8px; opacity: .8;
  transition: opacity .15s, background .15s;
}
.nav-btn:active { opacity: 1; background: rgba(255,255,255,.12); }
#nav-title { font-size: .85rem; opacity: .7; font-weight: 600; }

/* ─── App Container ─────────────────────────────────────────── */
#app-container {
  position: absolute;
  inset: 0;
  display: none;
  background: #0e0e1a;
  overflow-y: auto;
  z-index: 50;
}
.app-inner {
  padding: 16px;
  min-height: 100%;
}
.app-inner h2 { margin-bottom: 16px; font-size: 1.3rem; }
.app-inner h3 { margin: 12px 0 8px; font-size: 1rem; opacity: .9; }
.app-placeholder {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  height: 100%; gap: 12px; opacity: .7;
}

/* ─── Animations ─────────────────────────────────────────────── */
@keyframes slideUp {
  from { transform: translateY(100%); opacity:0; }
  to   { transform: translateY(0);    opacity:1; }
}
@keyframes slideDown {
  from { transform: translateY(0);    opacity:1; }
  to   { transform: translateY(100%); opacity:0; }
}

/* ─── Forms & Inputs ─────────────────────────────────────────── */
.inp {
  width: 100%;
  background: var(--surface2);
  border: 1px solid rgba(255,255,255,.15);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: .9rem;
  outline: none;
  transition: border .15s;
  margin-bottom: 8px;
  display: block;
}
.inp:focus { border-color: var(--accent); }
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; }

/* ─── Buttons ────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-install, .btn-installed, .btn-green, .btn-red {
  border: none; border-radius: 10px; padding: 10px 18px;
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn-primary { background: var(--accent2); color: #fff; }
.btn-secondary { background: var(--surface2); color: var(--text); }
.btn-green { background: var(--success); color: #fff; flex:1; }
.btn-red { background: var(--danger); color: #fff; padding: 10px 14px; }
.btn-install { background: var(--accent2); color: #fff; padding: 6px 14px; font-size:.8rem; }
.btn-installed { background: var(--surface); color: var(--text2); padding: 6px 14px; font-size:.8rem; }
.btn-back { background: none; border: none; color: var(--accent); cursor: pointer; padding: 4px 0; margin-bottom: 8px; font-size:.9rem; }
.btn-sm { background: var(--danger); color:#fff; border:none; border-radius:6px; padding:4px 8px; cursor:pointer; font-size:.75rem; }
button:active { opacity:.75; transform:scale(.97); }

/* ─── Toast ──────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 70px; left: 50%; transform: translateX(-50%);
  background: rgba(30,30,60,.95);
  border: 1px solid rgba(255,255,255,.15);
  backdrop-filter: blur(12px);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: .85rem;
  z-index: 9999;
  pointer-events: none;
  animation: toastAnim 2.8s ease forwards;
  white-space: nowrap;
}
@keyframes toastAnim {
  0%{opacity:0;transform:translateX(-50%) translateY(10px)}
  15%{opacity:1;transform:translateX(-50%) translateY(0)}
  75%{opacity:1}
  100%{opacity:0;transform:translateX(-50%) translateY(-10px)}
}

/* ─── Notification Panel ─────────────────────────────────────── */
#notif-panel {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: rgba(10,10,25,.96);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,.1);
  z-index: 800;
  max-height: 60%;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  padding: 16px;
}
#notif-panel h3 { margin-bottom: 12px; font-size: 1rem; }
.notif-item {
  background: var(--surface);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  border-left: 3px solid var(--accent);
}
.notif-item.read { border-left-color: rgba(255,255,255,.2); opacity:.65; }
.notif-item b { font-size: .9rem; }
.notif-item p { font-size: .8rem; opacity:.8; margin-top:2px; }
.notif-item small { font-size: .7rem; opacity:.5; }
#notif-list { padding-bottom: 8px; }
.close-notif { background: none; border:none; color:var(--text); font-size:1.2rem; cursor:pointer; align-self:flex-end; }

/* ─── Messages ───────────────────────────────────────────────── */
.thread-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px; border-radius: 12px;
  background: var(--surface); margin-bottom: 8px;
  cursor: pointer;
}
.thread-avatar {
  width: 42px; height: 42px;
  background: var(--accent2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1.1rem;
  flex-shrink: 0;
}
.chat-box { padding: 8px 0; min-height: 120px; max-height: 240px; overflow-y:auto; }
.bubble {
  max-width: 78%; margin-bottom: 6px; padding: 8px 12px;
  border-radius: 16px; font-size: .88rem; line-height: 1.4;
}
.bubble.out { background: var(--accent2); margin-left: auto; border-bottom-right-radius: 4px; }
.bubble.in { background: var(--surface2); margin-right: auto; border-bottom-left-radius: 4px; }

/* ─── Phone ──────────────────────────────────────────────────── */
.dial-display {
  font-size: 1.8rem; text-align: center;
  padding: 16px 0; letter-spacing: 4px;
  min-height: 60px; border-bottom: 1px solid rgba(255,255,255,.1);
  margin-bottom: 12px;
}
.dial-grid {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 8px;
}
.dial-btn {
  background: var(--surface2); border: none; color: var(--text);
  font-size: 1.3rem; padding: 14px; border-radius: 50%;
  cursor: pointer; transition: background .15s;
}
.dial-btn:active { background: rgba(255,255,255,.25); }

/* ─── Calculator ─────────────────────────────────────────────── */
.calc-display {
  font-size: 2.2rem; text-align: right;
  padding: 16px; background: var(--surface);
  border-radius: 12px; margin-bottom: 12px;
  word-break: break-all;
}
.calc-grid {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 8px;
}
.calc-btn {
  background: var(--surface2); border: none; color: var(--text);
  font-size: 1.1rem; padding: 16px 4px;
  border-radius: 12px; cursor: pointer;
}
.calc-op { background: var(--accent2); }
.calc-clear { background: var(--danger); }
.calc-btn:active { opacity:.7; }

/* ─── Store ──────────────────────────────────────────────────── */
.store-grid { display: flex; flex-direction: column; gap: 10px; }
.store-card {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border-radius: 14px; padding: 12px;
}
.store-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; flex-shrink: 0;
}
.store-info { flex: 1; }
.store-info b { display: block; font-size: .95rem; }
.store-info small { opacity: .6; font-size: .75rem; }

/* ─── Gallery ────────────────────────────────────────────────── */
.gallery-grid {
  display: flex; flex-wrap: wrap; gap: 4px;
}

/* ─── Contacts ───────────────────────────────────────────────── */
.contact-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px; border-radius: 10px;
  background: var(--surface); margin-bottom: 6px;
}

/* ─── Files ──────────────────────────────────────────────────── */
.file-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; background: var(--surface);
  border-radius: 10px; margin-bottom: 6px;
}

/* ─── Notes ──────────────────────────────────────────────────── */
.note-card {
  background: var(--surface); border-radius: 10px;
  padding: 12px; margin-bottom: 8px;
}
.note-card p { opacity:.7; font-size:.85rem; margin-top:4px; }

/* ─── Settings ───────────────────────────────────────────────── */
.settings-section {
  background: var(--surface); border-radius: 14px;
  padding: 14px; margin-bottom: 12px;
}
.settings-section h3 { margin-bottom: 10px; font-size:.9rem; opacity:.8; }
.setting-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,.06);
  font-size: .88rem;
}
.setting-row:last-child { border-bottom: none; }

/* ─── Weather ────────────────────────────────────────────────── */
.weather-details {
  display: grid; grid-template-columns: repeat(3,1fr);
  gap: 8px; margin-top: 20px; text-align: center;
}
.weather-details div {
  background: var(--surface); border-radius: 12px; padding: 10px 6px; font-size: .8rem;
}

/* ─── Browser ────────────────────────────────────────────────── */
.browser-bar {
  display: flex; gap: 8px; padding: 8px;
  background: rgba(0,0,0,.5);
}

/* ─── Music ──────────────────────────────────────────────────── */
.music-art {
  width: 140px; height: 140px; margin: 0 auto 16px;
  background: var(--surface2); border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 4rem;
}

/* ─── Games ──────────────────────────────────────────────────── */
.game-container { text-align: center; }
#score-board { margin-bottom: 10px; font-size: 1rem; font-weight: 600; }
.game-controls { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 12px; }
.game-controls div { display: flex; gap: 8px; }
.ctrl-btn {
  background: var(--surface2); border: none; color: var(--text);
  width: 48px; height: 48px; border-radius: 12px;
  font-size: 1.2rem; cursor: pointer;
}
.ctrl-btn:active { background: rgba(255,255,255,.25); }

/* ─── Memory ─────────────────────────────────────────────────── */
#mem-info { margin-bottom: 10px; font-size: .9rem; }
.memory-grid {
  display: grid; grid-template-columns: repeat(4,1fr); gap: 6px;
  max-width: 280px; margin: 0 auto;
}
.mem-card {
  height: 60px; background: var(--surface2); border-radius: 10px;
  cursor: pointer; perspective: 400px; position: relative;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; transition: background .2s;
}
.mem-front { font-size: 1.5rem; }
.mem-back { display: none; font-size: 1.5rem; }
.mem-card.flipped .mem-front { display: none; }
.mem-card.flipped .mem-back { display: block; }
.mem-card.matched { background: rgba(76,175,80,.3); }

/* ─── Login Form ─────────────────────────────────────────────── */
.login-form {
  background: var(--surface); border-radius: 16px;
  padding: 20px; max-width: 300px; margin: 0 auto;
}
.login-form h3 { margin-bottom: 14px; text-align: center; }

/* ─── Social ─────────────────────────────────────────────────── */
.feed { margin-top: 12px; }
.post-card {
  background: var(--surface); border-radius: 12px;
  padding: 12px; margin-bottom: 8px;
}
.post-card p { opacity: .85; font-size: .9rem; margin: 4px 0; }

/* ─── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,.2); border-radius: 4px; }

/* ─── Empty state ────────────────────────────────────────────── */
.empty { opacity:.5; text-align:center; padding:20px 0; font-size:.9rem; }