@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Bebas+Neue&family=Exo+2:ital,wght@0,300;0,400;0,700;1,300&family=Noto+Sans+Thai:wght@300;400;600&display=swap');

/* ─── Variables ─────────────────────────────── */
:root {
    --c-bg:        #04050f;
    --c-panel:     rgba(5, 10, 30, 0.85);
    --c-border:    rgba(0, 220, 255, 0.25);
    --c-border-hi: rgba(0, 220, 255, 0.7);
    --c-cyan:      #00dcff;
    --c-orange:    #ff6b00;
    --c-red:       #ff0055;
    --c-purple:    #7b2fff;
    --c-green:     #00ff88;
    --c-text:      #b0cce0;
    --c-dim:       rgba(176, 204, 224, 0.4);
    --font-mono:   'Share Tech Mono', monospace;
    --font-display:'Bebas Neue', cursive;
    --font-body:   'Noto Sans Thai', 'Exo 2', sans-serif;
}

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

body {
    background: var(--c-bg);
    color: var(--c-text);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ─── Grid Background ───────────────────────── */
.grid-bg {
    position: fixed;
    inset: 0;
    z-index: 0;
    background-image:
        linear-gradient(rgba(0,220,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,220,255,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
}

.grid-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse 80% 60% at 50% 50%,
        rgba(0,220,255,0.05) 0%,
        transparent 70%),
    radial-gradient(ellipse 40% 40% at 20% 80%,
        rgba(123,47,255,0.08) 0%,
        transparent 60%),
    radial-gradient(ellipse 40% 40% at 80% 20%,
        rgba(255,107,0,0.06) 0%,
        transparent 60%);
}

/* ─── Scanlines ─────────────────────────────── */
.scanlines {
    position: fixed;
    inset: 0;
    z-index: 999;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 3px,
        rgba(0,0,0,0.08) 3px,
        rgba(0,0,0,0.08) 4px
    );
    pointer-events: none;
    animation: scanMove 8s linear infinite;
}
@keyframes scanMove {
    0%   { background-position: 0 0; }
    100% { background-position: 0 400px; }
}

/* ─── Corner Brackets ───────────────────────── */
.corner {
    position: fixed;
    width: 28px;
    height: 28px;
    z-index: 10;
    pointer-events: none;
}
.corner-tl { top: 16px; left: 16px;
    border-top: 2px solid var(--c-cyan);
    border-left: 2px solid var(--c-cyan); }
.corner-tr { top: 16px; right: 16px;
    border-top: 2px solid var(--c-cyan);
    border-right: 2px solid var(--c-cyan); }
.corner-bl { bottom: 16px; left: 16px;
    border-bottom: 2px solid var(--c-cyan);
    border-left: 2px solid var(--c-cyan); }
.corner-br { bottom: 16px; right: 16px;
    border-bottom: 2px solid var(--c-cyan);
    border-right: 2px solid var(--c-cyan); }

/* ─── Container ─────────────────────────────── */
.container {
    position: relative;
    z-index: 2;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 20px;
    gap: 20px;
}

/* ─── Header ─────────────────────────────────── */
.header {
    width: 100%;
    max-width: 900px;
    display: flex;
    align-items: center;
    gap: 16px;
    animation: fadeSlideDown 0.7s cubic-bezier(.22,1,.36,1) both;
}
@keyframes fadeSlideDown {
    from { opacity:0; transform:translateY(-20px); }
    to   { opacity:1; transform:translateY(0); }
}

.header-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--c-cyan), transparent);
}

.header-content {
    text-align: center;
    flex-shrink: 0;
}

.system-id {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--c-dim);
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.main-title {
    font-family: var(--font-display);
    font-size: clamp(2.4rem, 6vw, 4rem);
    letter-spacing: 6px;
    line-height: 1;
    color: #fff;
    text-shadow: 0 0 20px rgba(0,220,255,0.5), 0 0 60px rgba(0,220,255,0.2);
}
.title-prefix { color: var(--c-cyan); }
.title-accent { color: var(--c-cyan); }

.owner-tag {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    letter-spacing: 3px;
    color: var(--c-dim);
    margin-top: 4px;
}

/* ─── HUD Grid ───────────────────────────────── */
.hud-grid {
    display: grid;
    grid-template-columns: 1fr 1.4fr 1fr;
    gap: 16px;
    width: 100%;
    max-width: 900px;
    animation: fadeSlideUp 0.7s cubic-bezier(.22,1,.36,1) 0.15s both;
}
@keyframes fadeSlideUp {
    from { opacity:0; transform:translateY(24px); }
    to   { opacity:1; transform:translateY(0); }
}

/* ─── Panels ─────────────────────────────────── */
.hud-panel {
    background: var(--c-panel);
    border: 1px solid var(--c-border);
    border-radius: 4px;
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.hud-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0,220,255,0.03) 0%, transparent 60%);
    pointer-events: none;
}
.hud-panel:hover {
    border-color: var(--c-border-hi);
    box-shadow: 0 0 30px rgba(0,220,255,0.1), inset 0 0 20px rgba(0,220,255,0.03);
}

/* Panel corner marks */
.hud-panel::after {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 10px; height: 10px;
    border-top: 1px solid var(--c-cyan);
    border-left: 1px solid var(--c-cyan);
}

.panel-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-body);
    font-size: 0.75rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(0,220,255,0.15);
    padding-bottom: 8px;
}
.panel-id   { color: var(--c-dim); font-family: var(--font-mono); font-size: 0.65rem; }
.center-panel .panel-title {
    color: var(--c-cyan);
    letter-spacing: 1px;
    text-align: center;
    font-size: 0.9rem;
    margin-left: 10px;
    flex: 1;
}
.panel-status {
    color: var(--c-green);
    letter-spacing: 1px;
}
.blink { animation: blink 1.4s step-end infinite; }
@keyframes blink {
    0%,100% { opacity:1; }
    50%      { opacity:0.2; }
}

/* ─── Circular Gauge ─────────────────────────── */
.gauge-wrap { width: 100%; display: flex; justify-content: center; }
.gauge { width: 120px; height: 120px; transform: rotate(-90deg); }

.gauge-track {
    fill: none;
    stroke: rgba(255,255,255,0.06);
    stroke-width: 8;
}
.gauge-fill {
    fill: none;
    stroke-width: 8;
    stroke-linecap: round;
    transition: stroke-dashoffset 1s cubic-bezier(.4,0,.2,1);
    filter: drop-shadow(0 0 6px currentColor);
}
.gauge-val {
    font-family: var(--font-display);
    font-size: 36px;
    fill: white;
    transform: rotate(90deg);
    transform-origin: 80px 80px;
}
.gauge-unit {
    font-family: var(--font-mono);
    font-size: 11px;
    fill: var(--c-dim);
    transform: rotate(90deg);
    transform-origin: 80px 80px;
}

/* ─── Sensor Progress Bar ────────────────────── */
.panel-bar {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.06);
    border-radius: 2px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    border-radius: 2px;
    width: 0%;
    transition: width 1s cubic-bezier(.4,0,.2,1);
}
.temp-bar {
    background: linear-gradient(90deg, var(--c-orange), var(--c-red));
    box-shadow: 0 0 8px var(--c-orange);
}
.humid-bar {
    background: linear-gradient(90deg, var(--c-cyan), var(--c-purple));
    box-shadow: 0 0 8px var(--c-cyan);
}

.panel-label {
    font-family: var(--font-body);
    font-size: 0.72rem;
    letter-spacing: 1px;
    color: var(--c-dim);
    text-align: center;
}

/* ─── Center Panel ───────────────────────────── */
.center-panel { gap: 16px; padding: 20px 18px; }

/* Power Ring */
.power-ring-wrap { position: relative; display: flex; flex-direction: column; align-items: center; gap: 0; }

.power-ring {
    position: relative;
    width: 160px;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ring-outer {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 1px solid rgba(0,220,255,0.2);
    animation: rotateRing 8s linear infinite;
}
.ring-outer::before {
    content: '';
    position: absolute;
    top: -4px; left: 50%;
    width: 8px; height: 8px;
    background: var(--c-cyan);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--c-cyan), 0 0 24px var(--c-cyan);
    transform: translateX(-50%);
}
.ring-outer::after {
    content: '';
    position: absolute;
    bottom: -4px; left: 50%;
    width: 4px; height: 4px;
    background: rgba(0,220,255,0.4);
    border-radius: 50%;
    transform: translateX(-50%);
}
@keyframes rotateRing { to { transform: rotate(360deg); } }

.ring-inner {
    position: absolute;
    inset: 18px;
    border-radius: 50%;
    border: 1px dashed rgba(0,220,255,0.1);
    animation: rotateRing 12s linear infinite reverse;
}

.ring-core {
    position: relative;
    z-index: 2;
    width: 100px; height: 100px;
    border-radius: 50%;
    background: rgba(5,10,30,0.95);
    border: 2px solid rgba(0,220,255,0.3);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    transition: border-color 0.4s, box-shadow 0.4s, background 0.4s;
    box-shadow: inset 0 0 24px rgba(0,220,255,0.06);
    cursor: pointer;
    user-select: none;
}
.ring-core:hover {
    border-color: rgba(0,220,255,0.7);
    box-shadow: inset 0 0 24px rgba(0,220,255,0.12), 0 0 30px rgba(0,220,255,0.25);
}
.ring-core:active { transform: scale(0.93); }

.ring-icon {
    font-size: 1.6rem;
    color: rgba(0,220,255,0.5);
    line-height: 1;
    transition: color 0.4s, text-shadow 0.4s, filter 0.4s;
}

.ring-status-text {
    font-family: var(--font-display);
    font-size: 1.1rem;
    letter-spacing: 3px;
    color: var(--c-dim);
    transition: color 0.4s, text-shadow 0.4s;
}

/* ON state */
.power-ring.on .ring-core {
    border-color: var(--c-cyan);
    box-shadow: inset 0 0 30px rgba(0,220,255,0.2),
                0 0 50px rgba(0,220,255,0.35);
    background: rgba(0,220,255,0.06);
}
.power-ring.on .ring-icon {
    color: #ffff00;
    text-shadow: 0 0 20px #ffff00, 0 0 40px rgba(255,255,0,0.6);
    filter: brightness(1.3) drop-shadow(0 0 8px #ffff00);
}
.power-ring.on .ring-status-text {
    color: var(--c-cyan);
    text-shadow: 0 0 16px var(--c-cyan);
}
.power-ring.on .ring-outer { border-color: rgba(0,220,255,0.45); }

/* ─── Status Readout ─────────────────────────── */
.status-readout {
    width: 100%;
    background: rgba(0,220,255,0.04);
    border: 1px solid rgba(0,220,255,0.15);
    border-radius: 6px;
    padding: 10px 14px;
    text-align: center;
}
.readout-label {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--c-dim);
    letter-spacing: 1px;
    margin-bottom: 4px;
    text-align: center;
    width: 100%;
}
.readout-value {
    font-family: var(--font-body);
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: #ff3366;
    text-shadow: 0 0 12px rgba(255,0,85,0.5);
    transition: color 0.4s, text-shadow 0.4s;
    text-align: center;
    width: 100%;
}
.readout-value.online {
    color: var(--c-cyan);
    text-shadow: 0 0 14px rgba(0,220,255,0.6);
}

/* ─── Voice Row ──────────────────────────────── */
.voice-row {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 4px;
}

.mic-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: transparent;
    border: 1px solid rgba(0,220,255,0.4);
    border-radius: 3px;
    color: var(--c-cyan);
    cursor: pointer;
    font-family: var(--font-body);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 10px 20px;
    transition: all 0.3s;
    position: relative;
    overflow: hidden;
}
.mic-btn::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(0,220,255,0.1) 50%, transparent 100%);
    transform: translateX(-100%);
    transition: transform 0.5s;
}
.mic-btn:hover { border-color: var(--c-cyan); box-shadow: 0 0 20px rgba(0,220,255,0.25); }
.mic-btn:hover::before { transform: translateX(100%); }
.mic-btn.recording {
    border-color: #ff0055;
    color: #ff0055;
    box-shadow: 0 0 20px rgba(255,0,85,0.4);
    animation: pulseRed 0.8s ease-in-out infinite;
}
@keyframes pulseRed {
    0%,100% { box-shadow: 0 0 10px rgba(255,0,85,0.3); }
    50%      { box-shadow: 0 0 25px rgba(255,0,85,0.7); }
}

.voice-hint {
    font-family: var(--font-body);
    font-size: 0.7rem;
    color: var(--c-dim);
}

/* Ring tap hint */
.ring-tap-hint {
    text-align: center;
    font-family: var(--font-body);
    font-size: 0.68rem;
    color: rgba(0,220,255,0.5);
    margin-top: 4px;
    letter-spacing: 0.5px;
}

/* ─── Footer Bar ─────────────────────────────── */
.footer-bar {
    display: flex;
    gap: 24px;
    align-items: center;
    font-family: var(--font-body);
    font-size: 0.7rem;
    letter-spacing: 0.5px;
    color: var(--c-dim);
    border-top: 1px solid rgba(0,220,255,0.1);
    padding-top: 12px;
    width: 100%;
    max-width: 900px;
    animation: fadeSlideUp 0.7s cubic-bezier(.22,1,.36,1) 0.3s both;
}
.footer-seg { display: flex; align-items: center; gap: 6px; }
.dot {
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #555;
}
.dot.online {
    background: var(--c-green);
    box-shadow: 0 0 6px var(--c-green);
    animation: dotBlink 2s ease-in-out infinite;
}
@keyframes dotBlink {
    0%,100% { opacity:1; }
    50%      { opacity:0.4; }
}

/* ─── Notification ───────────────────────────── */
.nx-notification {
    position: fixed;
    top: 24px; right: 24px;
    background: rgba(5,10,30,0.95);
    border: 1px solid var(--c-cyan);
    border-radius: 3px;
    padding: 12px 20px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--c-cyan);
    letter-spacing: 1px;
    z-index: 9999;
    box-shadow: 0 0 20px rgba(0,220,255,0.3);
    animation: notifIn 0.3s ease both;
}
@keyframes notifIn {
    from { opacity:0; transform: translateX(40px); }
    to   { opacity:1; transform: translateX(0); }
}
@keyframes notifOut {
    from { opacity:1; transform: translateX(0); }
    to   { opacity:0; transform: translateX(40px); }
}

/* ─── Responsive ─────────────────────────────── */
@media (max-width: 640px) {
    .hud-grid {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
    }
    .center-panel {
        grid-column: 1 / -1;
        order: -1;
    }
    .main-title { font-size: 2.2rem; letter-spacing: 4px; }
}