/* songyang-line — Design System (Dark Theme) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d1117; --surface: #161b22; --surface2: #21262d; --surface3: #2d333b;
  --border: #30363d; --accent: #58a6ff; --accent2: #79c0ff;
  --line-green: #06c755; --line-dark: #00b900;
  --orange: #f0883e; --green: #3fb950; --purple: #a371f7; --red: #f85149;
  --text: #e6edf3; --text2: #8b949e; --text3: #6e7681;
  --radius: 14px; --radius-sm: 10px;
}

body {
  font-family: 'Sarabun', sans-serif; background: var(--bg); color: var(--text);
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
  padding: 0; line-height: 1.5;
}

/* Password Gate */
.gate-overlay { position: fixed; inset: 0; background: var(--bg); z-index: 9999; display: flex; align-items: center; justify-content: center; padding: 20px; }
.gate-overlay.hidden { display: none; }
.gate-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 48px 36px; max-width: 420px; width: 100%; text-align: center; animation: fadeIn 0.5s ease; }
.gate-logo { font-size: 4rem; margin-bottom: 16px; filter: drop-shadow(0 0 24px rgba(6,199,85,0.5)); animation: float 3s ease-in-out infinite; }
.gate-card h1 { font-size: 1.8rem; font-weight: 800; background: linear-gradient(135deg, var(--line-green), var(--line-dark)); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; margin-bottom: 8px; }
.gate-card p { color: var(--text2); font-size: 0.95rem; margin-bottom: 28px; }
.gate-input { width: 100%; background: var(--surface2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: 'Sarabun', sans-serif; font-size: 1.1rem; font-weight: 600; padding: 14px 18px; outline: none; text-align: center; letter-spacing: 4px; transition: border-color 0.2s, box-shadow 0.2s; margin-bottom: 18px; }
.gate-input:focus { border-color: var(--line-green); box-shadow: 0 0 0 3px rgba(6,199,85,0.15); }
.gate-input.error { border-color: var(--red); animation: shake 0.4s ease; }
.gate-btn { width: 100%; padding: 14px; border: none; border-radius: var(--radius-sm); background: linear-gradient(135deg, var(--line-green), var(--line-dark)); color: #fff; font-family: 'Sarabun', sans-serif; font-size: 1.05rem; font-weight: 800; cursor: pointer; box-shadow: 0 4px 18px rgba(6,199,85,0.35); transition: all 0.25s; }
.gate-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }
.gate-error { color: var(--red); font-size: 0.85rem; font-weight: 600; margin-top: 12px; min-height: 1.2em; }

/* Main App */
.app-container { display: none; width: 100%; max-width: 720px; padding: 24px 16px 60px; flex-direction: column; align-items: center; }
.app-container.visible { display: flex; animation: fadeIn 0.5s ease; }

/* Header */
header { text-align: center; margin-bottom: 20px; margin-top: 8px; width: 100%; }
.back-link { display: inline-block; color: var(--text2); font-size: 0.85rem; font-weight: 600; text-decoration: none; margin-bottom: 12px; padding: 6px 14px; border-radius: 8px; background: var(--surface2); border: 1px solid var(--border); transition: all 0.25s; }
.back-link:hover { color: var(--line-green); border-color: var(--line-green); }
header h1 { font-size: 1.8rem; font-weight: 800; background: linear-gradient(135deg, var(--line-green), #39d0c8); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; line-height: 1.5; }
header .subtitle { color: var(--text2); font-size: 0.95rem; margin-top: 4px; }

/* Status Card */
.status-card { border-color: rgba(6,199,85,0.3); }
.status-row { display: flex; align-items: center; gap: 14px; }
.status-indicator { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; }
.status-indicator.connected { background: var(--line-green); box-shadow: 0 0 8px rgba(6,199,85,0.6); animation: pulse 2s ease-in-out infinite; }
.status-indicator.disconnected { background: var(--red); box-shadow: 0 0 8px rgba(248,81,73,0.6); }
.status-info h3 { font-size: 0.95rem; font-weight: 700; color: var(--line-green); }
.status-info p { font-size: 0.82rem; color: var(--text2); }

/* Tabs */
.tabs { display: flex; gap: 6px; width: 100%; margin-bottom: 16px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.tab { flex: 1; padding: 10px 8px; border: none; border-radius: 10px; background: transparent; color: var(--text2); font-family: 'Sarabun', sans-serif; font-size: 0.88rem; font-weight: 700; cursor: pointer; transition: all 0.25s; text-align: center; }
.tab.active { background: var(--surface2); color: var(--line-green); box-shadow: 0 2px 8px rgba(6,199,85,0.15); }
.tab-content { display: none; width: 100%; animation: fadeIn 0.3s ease; }
.tab-content.active { display: block; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.stat-mini { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px 10px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.stat-mini-icon { font-size: 1.3rem; }
.stat-mini-value { font-size: 1.5rem; font-weight: 800; color: var(--line-green); }
.stat-mini-label { font-size: 0.7rem; color: var(--text3); font-weight: 600; }

/* Card */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: 100%; margin-bottom: 16px; }
.card h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 18px; color: var(--text2); display: flex; align-items: center; gap: 8px; }
.card h2 span { font-size: 1.2em; }

/* Alert Types */
.alert-type-list { display: flex; flex-direction: column; gap: 12px; }
.alert-type-item { display: flex; align-items: center; gap: 12px; padding: 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; }
.alert-type-icon { width: 42px; height: 42px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; flex-shrink: 0; }
.alert-type-info { flex: 1; min-width: 0; }
.alert-type-info h3 { font-size: 0.88rem; font-weight: 700; }
.alert-type-info p { font-size: 0.75rem; color: var(--text3); }

/* Toggle */
.toggle { position: relative; width: 44px; height: 24px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; inset: 0; background: var(--surface3); border-radius: 24px; cursor: pointer; transition: 0.3s; }
.toggle-slider::before { content: ''; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: var(--text3); border-radius: 50%; transition: 0.3s; }
.toggle input:checked + .toggle-slider { background: var(--line-green); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); background: #fff; }

/* Form Fields */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 0.85rem; color: var(--text2); margin-bottom: 6px; font-weight: 600; }
.field input, .field select, .field textarea { width: 100%; background: var(--surface2); border: 1.5px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-family: 'Sarabun', sans-serif; font-size: 1rem; font-weight: 600; padding: 13px 14px; outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b949e' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.field textarea { resize: vertical; min-height: 80px; line-height: 1.8; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--line-green); box-shadow: 0 0 0 3px rgba(6,199,85,0.15); }
.field-hint { font-size: 0.75rem; color: var(--text3); margin-top: 4px; }
.field-hint a { text-decoration: none; }
.input-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint-text { color: var(--text3); font-size: 0.82rem; }

/* Buttons */
.btn-primary { width: 100%; padding: 16px; border: none; border-radius: var(--radius); background: linear-gradient(135deg, var(--accent), var(--accent2)); color: #fff; font-family: 'Sarabun', sans-serif; font-size: 1.1rem; font-weight: 800; cursor: pointer; box-shadow: 0 4px 20px rgba(88,166,255,0.35); transition: all 0.25s; }
.btn-line { background: linear-gradient(135deg, var(--line-green), var(--line-dark)); box-shadow: 0 4px 20px rgba(6,199,85,0.35); }
.btn-primary:hover { filter: brightness(1.1); transform: translateY(-1px); }
.btn-secondary { width: 100%; padding: 14px; border: 1.5px solid var(--border); border-radius: var(--radius); background: var(--surface2); color: var(--text2); font-family: 'Sarabun', sans-serif; font-size: 1rem; font-weight: 700; cursor: pointer; transition: all 0.25s; }
.btn-secondary:hover { border-color: var(--line-green); color: var(--text); }

/* Flex Message Preview */
.flex-preview { display: flex; justify-content: center; padding: 16px 0; }
.flex-card { background: #fff; border-radius: 16px; width: 100%; max-width: 320px; overflow: hidden; box-shadow: 0 4px 24px rgba(0,0,0,0.3); }
.flex-header { padding: 14px 16px 10px; }
.flex-badge { display: inline-block; font-size: 0.75rem; font-weight: 700; padding: 4px 12px; border-radius: 999px; }
.flex-badge.red { background: #fce8e6; color: #c5221f; }
.flex-badge.yellow { background: #fef3cd; color: #856404; }
.flex-badge.green { background: #e6f4ea; color: #137333; }
.flex-body { padding: 0 16px 14px; }
.flex-title { font-size: 1rem; font-weight: 700; color: #111; margin-bottom: 10px; }
.flex-detail { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.flex-detail span { font-size: 0.78rem; color: #555; }
.flex-progress { display: flex; align-items: center; gap: 8px; }
.flex-progress-bar { height: 8px; background: linear-gradient(90deg, var(--line-green), #39d0c8); border-radius: 4px; flex: 1; position: relative; }
.flex-progress-bar::before { content: ''; position: absolute; inset: 0; background: #e0e0e0; border-radius: 4px; z-index: -1; width: 133%; }
.flex-progress span { font-size: 0.82rem; font-weight: 700; color: var(--line-green); }
.flex-footer { border-top: 1px solid #eee; padding: 12px 16px; text-align: center; }
.flex-btn { border: none; background: none; color: var(--line-green); font-family: 'Sarabun'; font-size: 0.9rem; font-weight: 700; cursor: pointer; }

/* Setup Steps */
.setup-steps { display: flex; flex-direction: column; gap: 16px; }
.setup-step { display: flex; gap: 14px; align-items: flex-start; }
.step-num { width: 32px; height: 32px; border-radius: 50%; background: rgba(6,199,85,0.12); color: var(--line-green); font-weight: 800; font-size: 0.9rem; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step-content h4 { font-size: 0.9rem; font-weight: 700; margin-bottom: 2px; }
.step-content p { font-size: 0.8rem; color: var(--text2); line-height: 1.5; }
.step-content a { text-decoration: none; }

/* Log */
.log-list { display: flex; flex-direction: column; gap: 10px; }
.log-item { display: flex; gap: 12px; padding: 12px; background: var(--surface2); border-radius: 10px; align-items: center; }
.log-icon { font-size: 1.2rem; }
.log-info { flex: 1; }
.log-info h4 { font-size: 0.85rem; font-weight: 700; }
.log-info p { font-size: 0.75rem; color: var(--text3); }

/* Empty State */
.empty-state { text-align: center; padding: 40px 20px; }
.empty-icon { font-size: 3rem; margin-bottom: 12px; display: block; opacity: 0.5; }
.empty-state p { color: var(--text3); font-size: 0.95rem; }

/* Footer */
footer { color: var(--text2); font-size: 0.82rem; text-align: center; margin-top: 12px; padding-bottom: 24px; width: 100%; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Responsive */
@media (max-width: 480px) {
  header h1 { font-size: 1.5rem; }
  .card { padding: 18px 14px; }
  .input-grid { grid-template-columns: 1fr; }
  .stats-grid { gap: 8px; }
}
