:root { 
  --bg: #121212; --panel-bg: #1e1e1e; --fg: #e0e0e0; --muted: #757575; --line: #333; 
  --accent: #00bcd4; --accent-hover: #26c6da; --accent-fg: #000; --danger: #ef5350; --success: #00e676;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, monospace;
}
html, body { height: 100%; margin: 0; font-family: var(--font-ui); background: var(--bg); color: var(--fg); overflow: hidden; }

/* Login Page Styles */
.login-container { display: flex; align-items: center; justify-content: center; height: 100vh; position: absolute; top:0; left:0; width:100%; z-index: 9999; background: var(--bg); }
.login-box { background: var(--panel-bg); padding: 40px; border: 1px solid var(--line); width: 300px; box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.login-box h2 { margin: 0 0 24px 0; font-size: 18px; font-weight: 600; text-transform: uppercase; letter-spacing: 2px; color: var(--accent); text-align: center; }
.login-box input { width: 100%; box-sizing: border-box; background: #000; border: 1px solid var(--line); padding: 12px; color: #fff; margin-bottom: 12px; outline: none; transition: border-color 0.2s; }
.login-box input:focus { border-color: var(--accent); }
.login-box button { width: 100%; background: var(--accent); color: #000; border: none; padding: 12px; font-weight: 700; cursor: pointer; text-transform: uppercase; letter-spacing: 1px; transition: opacity 0.2s; }
.login-box button:hover { opacity: 0.9; }
.login-box label { display:block; margin-bottom:6px; font-size:12px; color: #888; text-transform:uppercase; letter-spacing:1px; }

/* Main App Layout */
.app-container { display: none; height: 100vh; flex-direction: column; } 
/* When active, set display flex via JS or override default */
#app-view[style*="display: block"] { display: flex !important; }

.navbar {
  height: 48px; background: #1a1a1a; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; padding: 0 16px;
  flex-shrink: 0;
}
.app-title { font-weight: 700; color: var(--accent); font-size: 16px; letter-spacing: 1px; }
.nav-controls { display: flex; gap: 12px; }
.nav-btn {
  background: transparent; border: 1px solid var(--line); color: var(--fg);
  padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer;
  transition: all 0.2s; border-radius: 4px;
}
.nav-btn:hover { background: #333; border-color: var(--muted); }
.nav-btn.logout { border-color: var(--danger); color: var(--danger); }
.nav-btn.logout:hover { background: rgba(239, 83, 80, 0.1); }

.wrap { display: grid; grid-template-columns: 320px minmax(0, 1fr) 360px; gap: 1px; flex: 1; min-height: 0; background: var(--line); }
.panel { background: var(--panel-bg); display: flex; flex-direction: column; min-height: 0; position: relative; min-width: 0; }
.panel-header { 
  padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px;
  color: var(--muted); display: flex; justify-content: space-between; align-items: center; flex-shrink: 0;
}

/* List Panel */
.list { overflow-y: auto; overflow-x: hidden; flex: 1 1 0; scrollbar-gutter: stable; }
.item { height: 60px; padding: 0 16px; border-bottom: 1px solid var(--line); cursor: pointer; display: flex; align-items: center; gap: 12px; transition: background 0.1s; }
.item:hover { background: #2a2a2a; }
.item.selected { background: #333; border-left: 3px solid var(--accent); padding-left: 13px; }
.thumb { width: 44px; height: 44px; background: #000; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); }
.thumb img { width: 100%; height: 100%; object-fit: cover; opacity: 0.8; transition: opacity 0.2s; }
.item:hover .thumb img, .item.selected .thumb img { opacity: 1; }
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { display: flex; gap: 6px; margin-top: 4px; }
.badge { font-size: 10px; padding: 2px 6px; border: 1px solid var(--line); color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; }
.badge[data-status="verified"] { border-color: var(--success); color: var(--success); }

/* Viewer */
.viewer { flex: 1; background: #000; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
/* Image Viewer Fix: Default hidden, displayed by JS when loaded */
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; } 

.images-strip { height: 100px; border-top: 1px solid var(--line); background: var(--panel-bg); display: flex; gap: 1px; overflow-x: auto; padding: 0; flex-shrink: 0; }
.strip-img { height: 100%; width: auto; aspect-ratio: 1/1; object-fit: cover; cursor: pointer; opacity: 0.6; border-right: 1px solid var(--line); transition: opacity 0.2s; }
.strip-img:hover { opacity: 1; }

/* Form */
.form-scroll { flex: 1; overflow-y: auto; padding: 20px; scrollbar-gutter: stable; }
.form-group { margin-bottom: 16px; }
label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); margin-bottom: 6px; }
input[type="text"], textarea { width: 100%; box-sizing: border-box; background: #121212; border: 1px solid var(--line); color: var(--fg); padding: 10px; font-size: 14px; border-radius: 0; transition: border-color 0.2s; }
input[type="text"]:focus, textarea:focus { border-color: var(--accent); outline: none; }
textarea { min-height: 80px; font-family: var(--font-mono); resize: vertical; }
.checkbox-group { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.checkbox-group label { margin: 0; cursor: pointer; color: var(--fg); }

/* Verified Button */
.verified-container { margin-bottom: 24px; }
.verified-toggle { display: none; }
.verified-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 16px; background: #2a2a2a; border: 1px solid var(--line); color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 2px; cursor: pointer; transition: all 0.2s ease; user-select: none; box-sizing: border-box; }
.verified-toggle:checked + .verified-btn { background: var(--success); color: #000; border-color: var(--success); box-shadow: 0 4px 15px rgba(0, 230, 118, 0.3); }

/* Controls */
.toolbar { padding: 16px; border-top: 1px solid var(--line); display: flex; gap: 12px; flex-shrink: 0; }
.btn { flex: 1; padding: 12px; background: transparent; border: 1px solid var(--line); color: var(--fg); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 1px; cursor: pointer; border-radius: 0; transition: all 0.1s; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn:hover { background: #2a2a2a; border-color: var(--muted); }
.btn:active { transform: translateY(1px); background: #222; }
.btn-primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn-success-flash { background: var(--success) !important; color: #000 !important; border-color: var(--success) !important; }

/* Filter & Help */
.filter-select { background: #000; color: var(--fg); border: 1px solid var(--line); padding: 4px 8px; font-size: 11px; margin-right: 8px; text-transform: uppercase; cursor: pointer; outline: none; }
.help-btn { width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); background: transparent; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold; }
.auto-advance-label { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); text-transform: uppercase; margin-bottom: 8px; cursor: pointer; }

/* Components */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-50px); background: var(--success); color: #000; padding: 12px 24px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; z-index: 3000; pointer-events: none; opacity: 0; transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.toast.active { transform: translateX(-50%) translateY(0); opacity: 1; }
.save-badge { background: var(--success); color: #000; padding: 2px 8px; font-size: 10px; font-weight: 800; }

.lightbox { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.95); z-index: 2000; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.2s; backdrop-filter: blur(8px); padding: 40px; box-sizing: border-box; }
.lightbox.active { opacity: 1; pointer-events: auto; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; box-shadow: 0 0 50px rgba(0,0,0,1); transform: scale(0.98); transition: transform 0.25s ease-out; cursor: zoom-out; }
.lightbox.active img { transform: scale(1); }
.lb-close { position: absolute; top: 20px; right: 20px; color: #fff; font-size: 28px; font-weight: bold; cursor: pointer; z-index: 2010; background: rgba(255, 255, 255, 0.2); width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border-radius: 50%; backdrop-filter: blur(4px); transition: all 0.2s; }
.lb-close:hover { background: rgba(239, 83, 80, 0.8); transform: rotate(90deg); }

.modal-content { 
  background: var(--panel-bg); border: 1px solid var(--line); 
  width: 700px; /* Wider */
  max-width: 95%; max-height: 90vh; overflow-y: auto; 
  padding: 32px; /* More padding */
  box-shadow: 0 20px 50px rgba(0,0,0,0.8); 
  transform: translateY(20px); transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
}
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 2500; display: flex; align-items: center; justify-content: center; opacity: 0; pointer-events: none; transition: opacity 0.2s; }
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-overlay.active .modal-content { transform: translateY(0); }
.modal-close { float: right; cursor: pointer; font-size: 24px; color: var(--muted); margin-top: -8px; }
.modal-close:hover { color: var(--fg); }

/* Help Content Styling */
.help-section { margin-bottom: 30px; }
.help-section h3 { 
  font-size: 16px; color: var(--accent); border-bottom: 1px solid var(--line); 
  padding-bottom: 8px; margin-bottom: 16px; text-transform: uppercase; letter-spacing: 1px;
}
.help-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.rule-item { 
  background: rgba(255,255,255,0.03); border: 1px solid var(--line); padding: 12px; border-radius: 6px; 
}
.rule-title { font-weight: 700; color: var(--fg); margin-bottom: 4px; display: block; }
.rule-desc { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* Help Modal Examples */
.example-case {
  background: #111; border: 1px solid var(--line); border-radius: 6px; padding: 12px;
}
.case-title {
  color: var(--accent); font-weight: bold; font-size: 13px; margin-bottom: 4px;
}
.case-desc {
  color: var(--muted); font-size: 12px; margin-bottom: 8px;
}
.case-img {
  width: 100%; height: auto; border-radius: 4px; border: 1px solid var(--line); margin-bottom: 8px;
}
.example-box { 
  background: #111; border-left: 3px solid var(--success); padding: 10px; 
  margin-top: 8px; font-family: var(--font-mono); font-size: 12px; color: #aaa;
}
.example-box .correct { color: var(--success); font-weight: bold; margin-right: 6px; }
.example-box .wrong { color: var(--danger); font-weight: bold; margin-right: 6px; }

/* Improved Hotkey Styling */
.hotkey-list { 
  display: grid; 
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); 
  gap: 12px; 
  margin-top: 12px; 
}
.hotkey-item { 
  background: #252525; 
  padding: 12px 16px; 
  border: 1px solid var(--line); 
  border-radius: 8px;
  font-size: 13px; 
  color: var(--fg);
  display: flex; 
  justify-content: space-between; 
  align-items: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.key-badge { 
  background: #333; 
  color: var(--accent); 
  padding: 4px 8px; 
  border-radius: 4px; 
  font-family: var(--font-mono); 
  font-weight: 700; 
  font-size: 12px;
  border: 1px solid #444; 
  border-bottom: 2px solid #111; /* Keycap effect */
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Utilities */
.lazy { opacity: 0; transition: opacity 0.3s; }
.lazy.ready { opacity: 1; }
.hidden { display: none !important; }
.kbd-shortcut { font-size: 10px; padding: 2px 4px; background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1); color: #FFF; /* Changed to white */ }
