:root {
  --bg: #020a14;
  --bg2: #071425;
  --card: rgba(9, 25, 47, 0.88);
  --card-2: rgba(8, 21, 40, 0.96);
  --line: rgba(64, 164, 255, 0.24);
  --text: #f7fbff;
  --muted: #94a8c2;
  --blue: #31a9ff;
  --cyan: #21dcff;
  --green: #3be889;
  --shadow: 0 16px 50px rgba(0, 30, 68, 0.35);
  --radius: 24px;
  --nav-h: 86px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background:
    radial-gradient(circle at top right, rgba(0, 128, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #020812, #06111f 45%, #050d1a);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
}

button, input, textarea {
  font: inherit;
}
button { cursor: pointer; color: inherit; }

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
}

.card {
  background: linear-gradient(180deg, rgba(10, 28, 52, 0.96), rgba(6, 18, 36, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,0.04);
}

.screen { display: none; }
.screen.active { display: block; }

.hero-header {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) 180px;
  gap: 14px;
  padding: 20px;
  margin-bottom: 14px;
}
.connection-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #bfd0e3;
  font-size: 14px;
  margin-bottom: 16px;
}
.status-dot, .device-dot, .blue-dot {
  width: 10px; height: 10px; border-radius: 50%; display: inline-block;
}
.status-dot, .device-dot { background: var(--green); box-shadow: 0 0 14px rgba(59,232,137,.75); }
.blue-dot { background: var(--blue); box-shadow: 0 0 14px rgba(49,169,255,.75); }

.hero-header h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 64px);
  line-height: .95;
  letter-spacing: -2px;
}
.hero-header h1 span {
  background: linear-gradient(120deg, var(--cyan), #2c82ff 72%);
  -webkit-background-clip: text;
  color: transparent;
}
.hero-header p { margin: 14px 0 0; color: var(--muted); font-size: 17px; }

.hero-side {
  display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 10px;
}
.mini-status {
  text-align: right; color: #bde5ff; font-size: 12px;
}
.mini-status strong { display:block; color:#e9f7ff; }
.orbital-core {
  width: 138px; height: 138px; position: relative; border-radius: 50%;
  background: radial-gradient(circle at center, rgba(30,197,255,.18), transparent 55%);
}
.core-ring {
  position: absolute; inset: 18px; border: 1px solid rgba(77, 201, 255, 0.65); border-radius: 50%;
  box-shadow: 0 0 24px rgba(33,220,255,.16) inset;
}
.core-ring-2 { inset: 0; opacity: .5; transform: rotate(28deg); }
.core-dot {
  position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 14px rgba(33,220,255,.65);
}
.d1 { left: 20px; bottom: 28px; }
.d2 { right: 30px; top: 24px; }
.d3 { left: 58px; top: 16px; }

.featured {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 18px 18px 20px;
  margin-bottom: 14px;
  position: relative;
  overflow: hidden;
}
.tag {
  position: absolute; top: 14px; left: 14px; padding: 5px 10px; border-radius: 999px;
  background: linear-gradient(135deg, #0d62bf, #1796ff); font-size: 12px; font-weight: 800;
}
.featured-main { display:flex; gap:16px; align-items:center; padding-top: 16px; }
.featured h2 { margin: 0 0 8px; font-size: clamp(24px, 5vw, 38px); }
.featured p { margin: 0 0 8px; color: var(--muted); }
.meta-line { display:flex; align-items:center; gap:8px; color:#d9ebff; }
.featured-icon.monitor {
  width: 60px; height: 48px; border: 2px solid var(--cyan); border-radius: 8px; position: relative;
  box-shadow: 0 0 20px rgba(33,220,255,.22);
}
.featured-icon.monitor::before {
  content:""; position:absolute; left:18px; top:14px; width:18px; height:10px; border:3px solid var(--cyan); border-left-color:transparent; border-right-color:transparent; border-bottom-color:transparent; border-radius:50%;
}
.featured-icon.monitor::after {
  content:""; position:absolute; left:23px; bottom:-8px; width:14px; height:3px; border-radius:999px; background:var(--cyan);
}
.featured-actions { display:flex; gap:10px; flex-wrap:wrap; margin-left:auto; }
.primary-btn, .ghost-btn, .save-btn, .outline-btn, .small-btn, .install-btn {
  min-height: 44px; border-radius: 14px; border: 1px solid rgba(65,170,255,.35); padding: 0 16px;
}
.primary-btn, .save-btn, .install-btn { background: linear-gradient(135deg, #0f6fd7, #1fb1ff); color:#fff; }
.ghost-btn, .outline-btn, .small-btn, .icon-btn { background: rgba(6,19,38,.9); color:#dcecff; }
.icon-btn { width: 44px; height: 44px; border-radius: 14px; border:1px solid var(--line); }

.cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 14px;
}
.app-card {
  text-align: left; padding: 18px; border: none;
}
.app-card h3 { margin: 12px 0 8px; font-size: 21px; }
.app-card p { margin: 0; color: var(--muted); line-height: 1.45; }
.app-icon {
  width: 56px; height: 56px; border-radius: 18px; display:grid; place-items:center;
  font-size: 30px; color: var(--cyan); border:1px solid rgba(57,208,255,.2);
  background: radial-gradient(circle at 50% 30%, rgba(28,162,255,.12), rgba(4,12,24,.2));
}
.app-icon.office::before {
  content: ""; width: 28px; height: 34px; display:block;
  background: linear-gradient(180deg, #38c6ff, #2f7dff);
  clip-path: polygon(0 100%,0 36%,42% 36%,42% 0,100% 0,100% 100%);
}
.app-icon.idea::before {
  content: ""; width: 24px; height: 34px; display:block; border: 3px solid var(--cyan); border-bottom-width:2px; border-radius: 50% 50% 40% 40%;
}
.app-icon.diary::before {
  content:""; width: 26px; height: 30px; display:block; border-radius: 8px; border:2px solid var(--cyan); position:relative;
}
.app-icon.setting { color:#9fd3ff; }
.wide-card { grid-column: span 2; }

.dashboard-grid {
  display:grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap:14px;
}
.panel { padding:18px; min-width:0; }
.section-head { display:flex; justify-content:space-between; align-items:center; gap:8px; margin-bottom:14px; }
.section-head h3 { margin:0; font-size:20px; }
.section-head span { color: var(--muted); font-size: 14px; }
.simple-list { list-style:none; padding:0; margin:0; display:grid; gap:12px; }
.simple-list li {
  display:flex; justify-content:space-between; align-items:center; gap:10px; padding:12px 14px; border-radius:16px; background: rgba(255,255,255,.02); border:1px solid rgba(255,255,255,.03);
}
.ok, .blue-badge { padding:6px 10px; border-radius:999px; font-size:13px; }
.ok { color:#bff9d8; background: rgba(59,232,137,.12); }
.blue-badge { color:#d6efff; background: rgba(49,169,255,.16); }
.health-wrap { display:grid; gap:16px; }
.health-ring {
  width: 156px; aspect-ratio:1; margin: 0 auto; border-radius:50%; display:grid; place-items:center; text-align:center;
  background: conic-gradient(var(--cyan) 0 78%, rgba(255,255,255,.06) 78% 100%);
  position:relative;
}
.health-ring::before {
  content:""; position:absolute; inset:16px; border-radius:50%; background:#071423; box-shadow: inset 0 0 20px rgba(0,0,0,.35);
}
.health-ring span, .health-ring small { position:relative; z-index:1; display:block; }
.health-ring span { font-size: 40px; font-weight: 800; }
.health-ring small { font-size: 20px; color:#6ef1b0; }
.meters label { display:flex; justify-content:space-between; color:#dbeaff; margin: 0 0 6px; }
.meter { height: 8px; border-radius: 999px; background: rgba(255,255,255,.08); margin-bottom: 12px; overflow:hidden; }
.meter i { display:block; height:100%; border-radius:999px; background: linear-gradient(90deg, #2ba8ff, var(--cyan)); }
.uptime { color: var(--muted); margin: 8px 0 0; display:flex; gap:8px; align-items:center; }
.device-list { display:grid; gap:12px; }
.device-item {
  display:flex; justify-content:space-between; align-items:center; padding:12px 14px; border-radius:16px; background: rgba(255,255,255,.02); border:1px solid rgba(255,255,255,.03);
}
.device-item small { display:block; color:#6ef1b0; margin-top:4px; }

.detail-header {
  display:flex; align-items:center; gap:14px; padding:14px 16px; margin-bottom:14px;
}
.detail-header small { color: var(--muted); }
.detail-header h2 { margin:2px 0 0; font-size: 24px; }
.detail-content { display:grid; gap:14px; }
.content-card { padding:18px; }
.content-card h3 { margin:0 0 14px; }
.form-grid { display:grid; gap:12px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0,1fr)); }
input, textarea {
  width:100%; background:#071120; color:var(--text); border:1px solid rgba(70,160,255,.22); border-radius:14px; padding:14px; outline:none;
}
textarea { min-height: 120px; resize: vertical; }
.list-box { display:grid; gap:12px; }
.list-item {
  display:grid; gap:8px; padding:14px; background: rgba(255,255,255,.02); border-radius:16px; border:1px solid rgba(255,255,255,.03);
}
.list-item-head { display:flex; justify-content:space-between; gap:10px; align-items:flex-start; }
.list-item-head b { font-size:18px; }
.list-item p, .list-item small { margin:0; color: var(--muted); }
.action-row { display:flex; gap:10px; flex-wrap:wrap; }
.empty-box {
  padding:18px; text-align:center; color: var(--muted); border: 1px dashed rgba(80,168,255,.25); border-radius:16px;
}
.settings-row { display:grid; gap:10px; }
.install-note { color: var(--muted); font-size: 14px; }

.bottom-nav {
  position: fixed;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(env(safe-area-inset-bottom) + 12px);
  max-width: 928px;
  margin: 0 auto;
  height: var(--nav-h);
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  align-items:center;
  padding: 8px;
  z-index: 30;
}
.nav-btn {
  border:none; background: transparent; height: 100%; border-radius: 18px; color: #9db2cb;
  display:grid; place-items:center; gap:4px;
}
.nav-btn span { font-size: 22px; }
.nav-btn small { font-size: 14px; }
.nav-btn.active {
  color: var(--blue);
  background: rgba(255,255,255,.03);
  box-shadow: inset 0 0 0 1px rgba(52,168,255,.08);
}

.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px); transform: translateX(-50%) translateY(12px);
  opacity: 0; pointer-events: none; transition: .2s ease; z-index: 40;
  background: rgba(3, 15, 30, .92); color: #eef8ff; border:1px solid rgba(76,177,255,.26); border-radius:999px; padding: 12px 16px;
}
.toast.show { opacity:1; transform: translateX(-50%) translateY(0); }

@media (max-width: 860px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .featured { flex-direction: column; align-items:flex-start; }
  .featured-actions { width:100%; margin-left:0; }
  .cards-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .wide-card { grid-column: span 2; }
}
@media (max-width: 520px) {
  .app-shell { padding-left: 12px; padding-right: 12px; }
  .hero-header {
    grid-template-columns: minmax(0, 1fr) 124px;
    gap: 10px;
    padding: 18px 14px;
    align-items: start;
  }
  .hero-side {
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
  }
  .orbital-core {
    width: 118px;
    height: 118px;
  }
  .mini-status {
    font-size: 10px;
    text-align: center;
  }
  .hero-header h1 {
    font-size: 46px;
    letter-spacing: -1.5px;
  }
  .hero-header p {
    font-size: 14px;
    line-height: 1.45;
    margin-top: 12px;
  }
  .connection-row {
    font-size: 13px;
    margin-bottom: 12px;
  }
  .cards-grid { grid-template-columns: 1fr; }
  .wide-card { grid-column: span 1; }
  .form-grid.two { grid-template-columns: 1fr; }
  .hero-header, .featured, .panel, .content-card { border-radius: 20px; }
  .featured h2 { font-size: 22px; }
  .app-card h3 { font-size: 19px; }
  .bottom-nav { left: 12px; right: 12px; height: 82px; }
}
@media (max-width: 390px) {
  .hero-header {
    grid-template-columns: minmax(0, 1fr) 108px;
    gap: 8px;
  }
  .hero-header h1 {
    font-size: 40px;
  }
  .orbital-core {
    width: 102px;
    height: 102px;
  }
}
@media (max-width: 430px) {
  .app-shell { padding-top: calc(env(safe-area-inset-top) + 10px); }
  body { background: linear-gradient(180deg, #020812, #06111f 45%, #050d1a); }
}
