:root {
    --bg-dark: #050608;
    --card-bg: rgba(255, 255, 255, 0.03);
    --text-main: #ffffff;
    --text-muted: #8b949e;
    
    --color-1: #ff3e8d; /* Rose */
    --color-2: #00f2ff; /* Cyan */
    --color-3: #7000ff; /* Purple */
    --color-4: #ffb800; /* Amber */
    --color-5: #00ff88; /* Emerald */
    --color-danger: #ef4444;
    
    --grad-1: linear-gradient(135deg, var(--color-1), var(--color-3));
    --font-header: 'Orbitron', 'Noto Sans TC', sans-serif;
    --font-ui: 'Inter', 'Noto Sans TC', sans-serif;
    --font-mono: 'Share Tech Mono', monospace;
}

/* Base Reset */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
    background-color: var(--bg-dark); 
    color: var(--text-main); 
    font-family: var(--font-ui); 
    height: 100vh; 
    width: 100vw;
    overflow: hidden; 
}

/* Login Overlay */
.login-overlay { position: fixed; inset: 0; background: var(--bg-dark); display: flex; align-items: center; justify-content: center; z-index: 10000; }
.login-box { text-align: center; width: 100%; max-width: 400px; padding: 40px; background: rgba(255,255,255,0.02); border: 1px solid rgba(255,255,255,0.05); border-radius: 20px; }
#loginPwd { width: 100%; padding: 15px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.1); color: white; text-align: center; font-size: 1.2rem; border-radius: 10px; margin-bottom: 20px; outline: none; }
#loginBtn { width: 100%; padding: 12px; background: var(--color-2); color: black; border: none; font-weight: 900; border-radius: 10px; cursor: pointer; }

/* Main Container */
.os-container { 
    width: 100%; 
    height: 100vh; 
    padding: 20px; 
    display: flex; 
    flex-direction: column; 
    gap: 15px;
}

/* Header */
.os-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    flex-shrink: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.logo-text { font-family: var(--font-header); font-size: 1.3rem; font-weight: 800; background: var(--grad-1); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.clock { font-family: var(--font-mono); background: rgba(255,255,255,0.05); padding: 5px 15px; border-radius: 10px; font-size: 0.9rem; }
.cmd-trigger { background: transparent; border: 1px solid var(--color-2); color: var(--color-2); padding: 6px 15px; border-radius: 8px; font-size: 0.75rem; font-family: var(--font-mono); cursor: pointer; transition: 0.2s; }
.cmd-trigger:hover { background: var(--color-2); color: #000; box-shadow: 0 0 15px var(--color-2); }

/* --- GRID SYSTEM (Fixed Overflow) --- */
.dashboard-grid { 
    display: grid; 
    grid-template-columns: 320px 1fr 340px; 
    grid-template-rows: 220px 1fr; 
    gap: 15px; 
    flex: 1; 
    min-height: 0; /* Critical for inner scrolling */
}

/* Widget Base */
.widget { 
    background: var(--card-bg); 
    border-radius: 18px; 
    border: 1px solid rgba(255, 255, 255, 0.05); 
    padding: 18px; 
    display: flex; 
    flex-direction: column; 
    min-height: 0; 
    min-width: 0;
}
.widget-header { flex-shrink: 0; margin-bottom: 12px; }
.widget-header h3 { font-size: 0.75rem; font-weight: 800; text-transform: uppercase; letter-spacing: 1px; }

/* Grid Mapping */
.status-widget { grid-column: 1 / 2; grid-row: 1 / 2; }
.focus-widget { grid-column: 2 / 3; grid-row: 1 / 2; text-align: center; justify-content: center; }
.todo-widget { grid-column: 3 / 4; grid-row: 1 / 3; }
.chat-widget { grid-column: 1 / 2; grid-row: 2 / 3; border: 1px solid rgba(0, 242, 255, 0.1); }
.memo-widget { grid-column: 2 / 3; grid-row: 2 / 3; }

/* 1. Subsystem Monitor */
.status-list { overflow-y: auto; flex: 1; }
.status-item { 
    cursor: pointer; display: flex; justify-content: space-between; align-items: center;
    background: rgba(255,255,255,0.02); padding: 10px 12px; border-radius: 8px; margin-bottom: 6px; 
    transition: 0.2s; font-size: 0.8rem;
}
.status-item:hover { background: rgba(0, 242, 255, 0.1); border-left: 3px solid var(--color-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.dot.online { background: var(--color-5); box-shadow: 0 0 8px var(--color-5); }
.dot.offline { background: var(--color-danger); box-shadow: 0 0 8px var(--color-danger); animation: blink 1s infinite; }

/* 2. Focus Protocol */
#dailyFocus { 
    width: 100%; background: transparent; border: 2px dashed rgba(255, 62, 141, 0.2); 
    border-radius: 12px; color: #fff; font-size: 1.8rem; font-weight: 900; text-align: center; 
    padding: 10px; outline: none; transition: 0.3s;
}
#dailyFocus:focus { border-color: var(--color-1); background: rgba(255,62,141,0.05); }
.focus-timer { font-family: var(--font-mono); font-size: 0.9rem; color: var(--color-1); text-align: center; margin-top: 10px; }

/* 3. Task Queue (Todo) - THE FIX */
.todo-input-area { display: flex; gap: 8px; flex-shrink: 0; margin-bottom: 12px; }
.todo-input-area input { 
    flex: 1; min-width: 0; background: rgba(0,0,0,0.3); border: 1px solid rgba(0, 255, 136, 0.2); 
    border-radius: 8px; color: white; padding: 10px; outline: none; font-size: 0.8rem;
}
.todo-input-area button { 
    flex-shrink: 0; background: var(--color-5); color: #000; border: none; width: 36px; 
    border-radius: 8px; font-weight: 900; cursor: pointer; 
}
.todo-list { list-style: none; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 8px; }
.todo-item { 
    display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
    background: rgba(255,255,255,0.03); padding: 12px; border-radius: 10px; 
    transition: 0.2s; min-height: 45px;
}
.todo-item span:first-child { flex: 1; word-break: break-all; font-size: 0.85rem; line-height: 1.3; }
.del-btn { color: #ff3e8d; cursor: pointer; font-weight: bold; opacity: 0.5; padding: 0 5px; }
.todo-item:hover .del-btn { opacity: 1; }

/* 4. Mini Chat UI */
.chat-messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.message { max-width: 90%; padding: 8px 12px; border-radius: 12px; font-size: 0.85rem; line-height: 1.4; word-wrap: break-word; }
.message.ai { align-self: flex-start; background: rgba(255, 255, 255, 0.05); color: #eee; border-bottom-left-radius: 2px; }
.message.user { align-self: flex-end; background: var(--color-2); color: #000; font-weight: 700; border-bottom-right-radius: 2px; }
.chat-input-area { display: flex; gap: 6px; flex-shrink: 0; }
.chat-input-area input { flex: 1; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); border-radius: 8px; color: white; padding: 8px; outline: none; font-size: 0.75rem; }
.chat-input-area button { background: var(--color-2); color: #000; border: none; padding: 0 12px; border-radius: 8px; font-weight: 900; cursor: pointer; font-size: 0.75rem; }

/* 5. Memo Pad */
#memoPad { width: 100%; flex: 1; background: rgba(0,0,0,0.2); border: 1px solid rgba(255, 184, 0, 0.1); border-radius: 15px; color: #eee; padding: 15px; font-size: 0.95rem; line-height: 1.6; resize: none; outline: none; }
.save-indicator { text-align: right; font-size: 0.65rem; color: var(--color-4); margin-top: 5px; font-weight: 800; flex-shrink: 0; }

/* Viewer Overlay (Iframe) */
.viewer-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(15px); display: none; align-items: center; justify-content: center; z-index: 20000; }
.viewer-box { width: 94%; height: 92%; background: #111; border: 2px solid var(--color-2); border-radius: 15px; overflow: hidden; display: flex; flex-direction: column; }
.viewer-header { background: #000; padding: 12px 20px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #333; }
.viewer-header span { font-family: var(--font-mono); color: var(--color-2); font-size: 0.8rem; }
.viewer-header button { background: transparent; border: 1px solid currentColor; padding: 5px 15px; border-radius: 5px; cursor: pointer; font-size: 0.75rem; font-weight: bold; }
.viewer-content { flex: 1; background: #fff; }
.viewer-content iframe { width: 100%; height: 100%; border: none; }

/* Command Palette Overlay */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.9); backdrop-filter: blur(10px); display: none; align-items: center; justify-content: center; z-index: 15000; }
.cmd-box { background: #0a0a0a; border: 2px solid var(--color-2); width: 100%; max-width: 500px; padding: 30px; border-radius: 20px; box-shadow: 0 0 50px rgba(0, 242, 255, 0.2); }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

/* Responsive */
@media (max-width: 1100px) {
    .dashboard-grid { display: flex; flex-direction: column; overflow-y: auto; }
    body { overflow: auto; }
}
