/* ═══════════════════════════════════════════════════════════
   NexDoc Suite - Stylesheet v1.0
   Inteligentni uredski paket nove generacije
   100% originalni dizajn - Flow Panel, Quick Ring, Voice Bar
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Variables / Theme System ── */
:root {
  --nx-primary: #4A3AFF;
  --nx-primary-light: #6B5CFF;
  --nx-primary-dark: #3828CC;
  --nx-accent: #00D4AA;
  --nx-accent-light: #33DDBB;
  --nx-accent-dark: #00A888;
  --nx-danger: #FF4757;
  --nx-warning: #FFA502;
  --nx-success: #2ED573;
  --nx-info: #1E90FF;

  --nx-font-sans: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --nx-font-mono: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', monospace;

  --nx-radius-sm: 4px;
  --nx-radius-md: 8px;
  --nx-radius-lg: 12px;
  --nx-radius-xl: 16px;
  --nx-radius-full: 9999px;

  --nx-shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
  --nx-shadow-md: 0 4px 12px rgba(0,0,0,0.15);
  --nx-shadow-lg: 0 8px 32px rgba(0,0,0,0.2);
  --nx-shadow-xl: 0 16px 48px rgba(0,0,0,0.25);

  --nx-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --nx-flow-width: 260px;
  --nx-nexmind-width: 320px;
  --nx-voicebar-height: 48px;
  --nx-statusdock-height: 28px;
}

/* ── Dark Theme (default) ── */
[data-theme="dark"] {
  --nx-bg-base: #0A0A14;
  --nx-bg-surface: #12121E;
  --nx-bg-elevated: #1A1A2E;
  --nx-bg-overlay: #22223A;
  --nx-bg-input: #16162A;
  --nx-bg-hover: rgba(74, 58, 255, 0.12);
  --nx-bg-active: rgba(74, 58, 255, 0.2);
  --nx-bg-page: #1E1E32;

  --nx-text-primary: #E8E8F0;
  --nx-text-secondary: #9494B8;
  --nx-text-tertiary: #6060808;
  --nx-text-inverse: #0A0A14;

  --nx-border: #2A2A44;
  --nx-border-light: #1E1E36;
  --nx-border-focus: var(--nx-primary);

  --nx-scrollbar-track: #12121E;
  --nx-scrollbar-thumb: #2A2A44;
  --nx-scrollbar-hover: #3A3A5A;

  --nx-writer-bg: #1C1C30;
  --nx-writer-page: #242440;
  --nx-writer-text: #E0E0F0;
  --nx-calc-grid: #2A2A44;
  --nx-calc-header: #16162A;
  --nx-calc-cell-bg: #1A1A2E;
  --nx-calc-selected: rgba(74, 58, 255, 0.25);
}

/* ── Light Theme ── */
[data-theme="light"] {
  --nx-bg-base: #F0F0F8;
  --nx-bg-surface: #FFFFFF;
  --nx-bg-elevated: #F8F8FC;
  --nx-bg-overlay: #EDEDF5;
  --nx-bg-input: #F5F5FA;
  --nx-bg-hover: rgba(74, 58, 255, 0.06);
  --nx-bg-active: rgba(74, 58, 255, 0.12);
  --nx-bg-page: #FFFFFF;

  --nx-text-primary: #1A1A2E;
  --nx-text-secondary: #6A6A8A;
  --nx-text-tertiary: #9A9AB0;
  --nx-text-inverse: #FFFFFF;

  --nx-border: #D8D8E8;
  --nx-border-light: #E8E8F0;
  --nx-border-focus: var(--nx-primary);

  --nx-scrollbar-track: #F0F0F8;
  --nx-scrollbar-thumb: #C8C8D8;
  --nx-scrollbar-hover: #B0B0C8;

  --nx-writer-bg: #F5F5FA;
  --nx-writer-page: #FFFFFF;
  --nx-writer-text: #1A1A2E;
  --nx-calc-grid: #D8D8E8;
  --nx-calc-header: #EDEDF5;
  --nx-calc-cell-bg: #FFFFFF;
  --nx-calc-selected: rgba(74, 58, 255, 0.12);
}

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

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--nx-font-sans);
  font-size: 14px;
  color: var(--nx-text-primary);
  background: var(--nx-bg-base);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--nx-scrollbar-track); }
::-webkit-scrollbar-thumb { background: var(--nx-scrollbar-thumb); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--nx-scrollbar-hover); }

.hidden { display: none !important; }

/* ══════════════════════════════
   SPLASH SCREEN
   ══════════════════════════════ */
.splash {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0A0A14 0%, #1A1A2E 50%, #0F0F2A 100%);
}
.splash-logo { text-align: center; animation: fadeInUp 0.6s ease; }
.splash-logo svg { margin-bottom: 16px; filter: drop-shadow(0 4px 20px rgba(74,58,255,0.4)); }
.splash-logo h1 {
  font-size: 32px; font-weight: 700; color: #E8E8F0;
  background: linear-gradient(135deg, #4A3AFF, #00D4AA);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 8px;
}
.splash-logo p { color: #9494B8; font-size: 14px; margin-bottom: 24px; }
.splash-progress {
  width: 200px; height: 3px; background: #2A2A44;
  border-radius: 2px; margin: 0 auto; overflow: hidden;
}
.splash-bar {
  width: 0%; height: 100%; border-radius: 2px;
  background: linear-gradient(90deg, #4A3AFF, #00D4AA);
  animation: splashLoad 1.5s ease forwards;
}
@keyframes splashLoad { to { width: 100%; } }
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════
   WELCOME SCREEN
   ══════════════════════════════ */
.welcome {
  position: fixed; inset: 0; z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  background: var(--nx-bg-base);
  overflow-y: auto;
}
.welcome-content {
  width: 100%; max-width: 720px; padding: 48px 32px;
  animation: fadeInUp 0.4s ease;
}
.welcome-header { text-align: center; margin-bottom: 40px; }
.welcome-header svg { filter: drop-shadow(0 4px 20px rgba(74,58,255,0.3)); }
.welcome-header h1 {
  font-size: 28px; font-weight: 700; margin-top: 12px;
  background: linear-gradient(135deg, #4A3AFF, #00D4AA);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}
.welcome-version { color: var(--nx-text-tertiary); font-size: 13px; margin-top: 4px; }

.welcome-actions h2 {
  font-size: 13px; font-weight: 600; color: var(--nx-text-secondary);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 12px; margin-top: 28px;
}
.welcome-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.welcome-card {
  background: var(--nx-bg-surface); border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-lg); padding: 24px; cursor: pointer;
  transition: all var(--nx-transition); text-align: center;
}
.welcome-card:hover {
  border-color: var(--nx-primary); background: var(--nx-bg-hover);
  transform: translateY(-2px); box-shadow: var(--nx-shadow-md);
}
.card-icon { margin-bottom: 12px; }
.writer-icon { color: var(--nx-primary); }
.calc-icon { color: var(--nx-accent); }
.welcome-card h3 { font-size: 16px; font-weight: 600; margin-bottom: 4px; }
.welcome-card p { font-size: 13px; color: var(--nx-text-secondary); }

.btn-open {
  display: flex; align-items: center; gap: 8px;
  background: var(--nx-bg-surface); border: 1px dashed var(--nx-border);
  color: var(--nx-text-primary); padding: 12px 20px; border-radius: var(--nx-radius-md);
  cursor: pointer; font-size: 14px; transition: all var(--nx-transition); width: 100%;
  justify-content: center;
}
.btn-open:hover { border-color: var(--nx-primary); background: var(--nx-bg-hover); }
.supported-formats { font-size: 12px; color: var(--nx-text-tertiary); margin-top: 8px; text-align: center; }

.recent-list { display: flex; flex-direction: column; gap: 4px; }
.recent-item {
  display: flex; align-items: center; gap: 12px; padding: 8px 12px;
  border-radius: var(--nx-radius-md); cursor: pointer; transition: background var(--nx-transition);
}
.recent-item:hover { background: var(--nx-bg-hover); }
.recent-item .ri-icon { color: var(--nx-text-secondary); flex-shrink: 0; }
.recent-item .ri-name { font-size: 14px; flex: 1; }
.recent-item .ri-date { font-size: 12px; color: var(--nx-text-tertiary); }

.welcome-footer {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--nx-border);
  color: var(--nx-text-tertiary); font-size: 12px;
}
.theme-toggle {
  background: none; border: none; color: var(--nx-text-secondary);
  cursor: pointer; padding: 4px; border-radius: var(--nx-radius-sm);
  transition: color var(--nx-transition);
}
.theme-toggle:hover { color: var(--nx-primary); }

/* ══════════════════════════════
   MAIN APP LAYOUT
   ══════════════════════════════ */
.app {
  display: flex; flex-direction: column; height: 100vh;
  background: var(--nx-bg-base);
}
.app-body {
  display: flex; flex: 1; overflow: hidden;
}

/* ── Voice Bar ── */
.voice-bar {
  height: var(--nx-voicebar-height);
  background: var(--nx-bg-surface);
  border-bottom: 1px solid var(--nx-border);
  display: flex; align-items: center;
  padding: 0 8px; gap: 8px; z-index: 100;
  -webkit-app-region: drag;
}
.vb-left, .vb-right { display: flex; align-items: center; gap: 4px; -webkit-app-region: no-drag; }
.vb-left { flex: 1; min-width: 0; }
.vb-center { -webkit-app-region: no-drag; }
.vb-right { flex-shrink: 0; }

.vb-home {
  background: none; border: none; cursor: pointer; padding: 4px;
  border-radius: var(--nx-radius-sm); transition: opacity var(--nx-transition);
  display: flex; align-items: center;
}
.vb-home:hover { opacity: 0.8; }

.vb-tabs {
  display: flex; gap: 2px; overflow-x: auto; max-width: 500px;
  scrollbar-width: none;
}
.vb-tabs::-webkit-scrollbar { display: none; }
.vb-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--nx-radius-sm);
  background: transparent; border: none; color: var(--nx-text-secondary);
  cursor: pointer; font-size: 13px; white-space: nowrap;
  transition: all var(--nx-transition); max-width: 160px;
}
.vb-tab:hover { background: var(--nx-bg-hover); color: var(--nx-text-primary); }
.vb-tab.active {
  background: var(--nx-bg-active); color: var(--nx-text-primary); font-weight: 500;
}
.vb-tab .tab-close {
  width: 16px; height: 16px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 14px;
  opacity: 0; transition: opacity var(--nx-transition);
  color: var(--nx-text-secondary);
}
.vb-tab:hover .tab-close { opacity: 1; }
.vb-tab .tab-close:hover { background: var(--nx-danger); color: white; }

.vb-new-tab {
  background: none; border: none; color: var(--nx-text-secondary);
  cursor: pointer; font-size: 18px; padding: 4px 8px;
  border-radius: var(--nx-radius-sm); transition: all var(--nx-transition);
}
.vb-new-tab:hover { background: var(--nx-bg-hover); color: var(--nx-text-primary); }

.vb-voice-control {
  display: flex; align-items: center; gap: 8px;
  background: var(--nx-bg-elevated); padding: 4px 12px 4px 4px;
  border-radius: var(--nx-radius-full); border: 1px solid var(--nx-border);
}
.vb-mic {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--nx-bg-overlay); border: none; color: var(--nx-text-secondary);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--nx-transition);
}
.vb-mic:hover { background: var(--nx-primary); color: white; }
.vb-mic.active {
  background: var(--nx-danger); color: white;
  animation: pulse 1.5s infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,71,87,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(255,71,87,0); }
}

.vb-voice-status { display: flex; align-items: center; gap: 6px; }
.voice-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--nx-text-tertiary);
}
.voice-dot.listening { background: var(--nx-danger); animation: pulse 1s infinite; }
.voice-dot.ready { background: var(--nx-success); }
.voice-text { font-size: 12px; color: var(--nx-text-secondary); max-width: 200px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.vb-voice-wave {
  display: none; gap: 2px; align-items: center; height: 20px;
}
.vb-voice-wave.active { display: flex; }
.vb-voice-wave span {
  width: 3px; background: var(--nx-danger); border-radius: 2px;
  animation: wave 0.5s ease infinite alternate;
}
.vb-voice-wave span:nth-child(1) { height: 8px; animation-delay: 0s; }
.vb-voice-wave span:nth-child(2) { height: 14px; animation-delay: 0.1s; }
.vb-voice-wave span:nth-child(3) { height: 20px; animation-delay: 0.2s; }
.vb-voice-wave span:nth-child(4) { height: 14px; animation-delay: 0.3s; }
.vb-voice-wave span:nth-child(5) { height: 8px; animation-delay: 0.4s; }
@keyframes wave {
  from { height: 4px; }
  to { height: 20px; }
}

.vb-btn {
  background: none; border: none; color: var(--nx-text-secondary);
  cursor: pointer; padding: 6px; border-radius: var(--nx-radius-sm);
  transition: all var(--nx-transition); display: flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 500;
}
.vb-btn:hover { background: var(--nx-bg-hover); color: var(--nx-text-primary); }
.vb-btn:active { background: var(--nx-bg-active); }

/* ── Flow Panel ── */
.flow-panel {
  width: var(--nx-flow-width); min-width: var(--nx-flow-width);
  background: var(--nx-bg-surface);
  border-right: 1px solid var(--nx-border);
  display: flex; flex-direction: column;
  transition: width var(--nx-transition), min-width var(--nx-transition);
  overflow: hidden; z-index: 50;
}
.flow-panel.collapsed { width: 0; min-width: 0; border-right: none; }

.fp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--nx-border);
}
.fp-title {
  font-size: 12px; font-weight: 600; color: var(--nx-text-secondary);
  text-transform: uppercase; letter-spacing: 1px;
}
.fp-collapse {
  background: none; border: none; color: var(--nx-text-secondary);
  cursor: pointer; padding: 4px; border-radius: var(--nx-radius-sm);
  transition: all var(--nx-transition);
}
.fp-collapse:hover { background: var(--nx-bg-hover); color: var(--nx-text-primary); }
.flow-panel.collapsed .fp-collapse svg { transform: rotate(180deg); }

.fp-content {
  flex: 1; overflow-y: auto; padding: 8px;
}
.fp-section { margin-bottom: 8px; }
.fp-section-title {
  font-size: 11px; font-weight: 600; color: var(--nx-text-tertiary);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding: 8px 8px 4px; display: flex; align-items: center; gap: 6px;
}
.fp-group {
  display: flex; flex-wrap: wrap; gap: 2px; padding: 4px;
}
.fp-btn {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--nx-radius-sm);
  background: none; border: none; color: var(--nx-text-secondary);
  cursor: pointer; transition: all var(--nx-transition); position: relative;
}
.fp-btn:hover { background: var(--nx-bg-hover); color: var(--nx-text-primary); }
.fp-btn:active { background: var(--nx-bg-active); }
.fp-btn.active { background: var(--nx-bg-active); color: var(--nx-primary); }
.fp-btn[title]::after {
  content: attr(title); position: absolute; left: 100%; top: 50%;
  transform: translateY(-50%); background: var(--nx-bg-overlay);
  color: var(--nx-text-primary); padding: 4px 8px; border-radius: var(--nx-radius-sm);
  font-size: 12px; white-space: nowrap; pointer-events: none;
  opacity: 0; transition: opacity 0.15s; z-index: 100;
  border: 1px solid var(--nx-border); margin-left: 4px;
}
.fp-btn:hover[title]::after { opacity: 1; }

.fp-divider { height: 1px; background: var(--nx-border); margin: 4px 8px; }

.fp-color-grid {
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; padding: 4px;
}
.fp-color-swatch {
  width: 24px; height: 24px; border-radius: var(--nx-radius-sm);
  border: 2px solid transparent; cursor: pointer;
  transition: border-color var(--nx-transition), transform 0.1s;
}
.fp-color-swatch:hover { border-color: var(--nx-text-primary); transform: scale(1.15); }
.fp-color-swatch.active { border-color: var(--nx-primary); }

.fp-select {
  width: 100%; padding: 6px 8px; background: var(--nx-bg-input);
  border: 1px solid var(--nx-border); border-radius: var(--nx-radius-sm);
  color: var(--nx-text-primary); font-size: 13px; cursor: pointer;
  margin: 4px 0;
}
.fp-select:focus { border-color: var(--nx-primary); outline: none; }

.fp-input {
  width: 100%; padding: 6px 8px; background: var(--nx-bg-input);
  border: 1px solid var(--nx-border); border-radius: var(--nx-radius-sm);
  color: var(--nx-text-primary); font-size: 13px; margin: 4px 0;
}
.fp-input:focus { border-color: var(--nx-primary); outline: none; }

.fp-range-row {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px;
}
.fp-range-label { font-size: 12px; color: var(--nx-text-secondary); min-width: 40px; }
.fp-range {
  flex: 1; -webkit-appearance: none; height: 4px;
  background: var(--nx-border); border-radius: 2px; outline: none;
}
.fp-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px;
  background: var(--nx-primary); border-radius: 50%; cursor: pointer;
}
.fp-range-val { font-size: 12px; color: var(--nx-text-secondary); min-width: 30px; text-align: right; }

/* ── Canvas Area ── */
.canvas-area {
  flex: 1; overflow: hidden; display: flex; flex-direction: column;
  background: var(--nx-bg-base);
}

/* ── Writer ── */
.writer-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.writer-toolbar {
  display: flex; align-items: center; gap: 2px; padding: 4px 8px;
  background: var(--nx-bg-surface); border-bottom: 1px solid var(--nx-border);
  flex-wrap: wrap; min-height: 40px;
}
.wt-btn {
  display: flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; border-radius: var(--nx-radius-sm);
  background: none; border: none; color: var(--nx-text-secondary);
  cursor: pointer; transition: all var(--nx-transition); padding: 0 6px;
  font-size: 13px;
}
.wt-btn:hover { background: var(--nx-bg-hover); color: var(--nx-text-primary); }
.wt-btn:active { background: var(--nx-bg-active); }
.wt-btn.active { background: var(--nx-bg-active); color: var(--nx-primary); }

.wt-select {
  height: 32px; padding: 0 8px; background: var(--nx-bg-input);
  border: 1px solid var(--nx-border); border-radius: var(--nx-radius-sm);
  color: var(--nx-text-primary); font-size: 13px; cursor: pointer;
}
.wt-select:focus { border-color: var(--nx-primary); outline: none; }

.wt-separator { width: 1px; height: 24px; background: var(--nx-border); margin: 0 4px; }

.wt-color-input {
  width: 32px; height: 32px; border: none; padding: 2px;
  background: none; cursor: pointer; border-radius: var(--nx-radius-sm);
}

.writer-ruler {
  height: 24px; background: var(--nx-bg-elevated);
  border-bottom: 1px solid var(--nx-border);
  position: relative;
}

.writer-scroll {
  flex: 1; overflow-y: auto; background: var(--nx-writer-bg);
  display: flex; justify-content: center; padding: 32px 16px;
}
.writer-page {
  width: 210mm; min-height: 297mm; background: var(--nx-writer-page);
  box-shadow: var(--nx-shadow-lg); border-radius: 2px;
  padding: 25.4mm; position: relative;
  transition: transform var(--nx-transition);
}
.writer-content {
  outline: none; min-height: 100%; font-family: var(--nx-font-sans);
  font-size: 16px; line-height: 1.6; color: var(--nx-writer-text);
  user-select: text; cursor: text; word-wrap: break-word;
  overflow-wrap: break-word;
}
.writer-content:empty::before {
  content: 'Počnite pisati ili koristite glasovnu naredbu...';
  color: var(--nx-text-tertiary); font-style: italic;
}
.writer-content h1 { font-size: 28px; font-weight: 700; margin: 16px 0 8px; line-height: 1.3; }
.writer-content h2 { font-size: 22px; font-weight: 600; margin: 14px 0 6px; line-height: 1.3; }
.writer-content h3 { font-size: 18px; font-weight: 600; margin: 12px 0 4px; line-height: 1.4; }
.writer-content p { margin: 8px 0; }
.writer-content ul, .writer-content ol { margin: 8px 0; padding-left: 24px; }
.writer-content li { margin: 4px 0; }
.writer-content blockquote {
  border-left: 4px solid var(--nx-primary); padding: 8px 16px;
  margin: 12px 0; background: var(--nx-bg-hover); border-radius: 0 var(--nx-radius-sm) var(--nx-radius-sm) 0;
  font-style: italic; color: var(--nx-text-secondary);
}
.writer-content table {
  border-collapse: collapse; width: 100%; margin: 12px 0;
}
.writer-content table td, .writer-content table th {
  border: 1px solid var(--nx-border); padding: 8px 12px;
  text-align: left; min-width: 60px;
}
.writer-content table th { background: var(--nx-bg-elevated); font-weight: 600; }
.writer-content img { max-width: 100%; height: auto; border-radius: var(--nx-radius-sm); }
.writer-content a { color: var(--nx-primary); text-decoration: underline; }
.writer-content hr {
  border: none; height: 2px; background: var(--nx-border); margin: 16px 0;
}
.writer-content pre {
  background: var(--nx-bg-base); padding: 16px; border-radius: var(--nx-radius-md);
  font-family: var(--nx-font-mono); font-size: 14px; overflow-x: auto;
  border: 1px solid var(--nx-border); margin: 12px 0;
}
.writer-content code {
  background: var(--nx-bg-overlay); padding: 2px 6px; border-radius: 3px;
  font-family: var(--nx-font-mono); font-size: 13px;
}

/* ── Calc ── */
.calc-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.calc-toolbar {
  display: flex; align-items: center; gap: 2px; padding: 4px 8px;
  background: var(--nx-bg-surface); border-bottom: 1px solid var(--nx-border);
  flex-wrap: wrap; min-height: 40px;
}

.calc-formula-bar {
  display: flex; align-items: center; background: var(--nx-bg-surface);
  border-bottom: 1px solid var(--nx-border); height: 32px;
}
.cfb-cell-ref {
  width: 80px; padding: 0 8px; font-size: 13px; font-weight: 500;
  color: var(--nx-text-primary); background: var(--nx-bg-elevated);
  border-right: 1px solid var(--nx-border); height: 100%;
  display: flex; align-items: center; font-family: var(--nx-font-mono);
  cursor: pointer;
}
.cfb-fx {
  padding: 0 8px; font-size: 13px; font-style: italic; font-weight: 600;
  color: var(--nx-text-tertiary); border-right: 1px solid var(--nx-border);
  height: 100%; display: flex; align-items: center;
}
.cfb-input {
  flex: 1; padding: 0 8px; background: var(--nx-bg-surface);
  border: none; color: var(--nx-text-primary); font-size: 13px;
  font-family: var(--nx-font-mono); height: 100%; outline: none;
}
.cfb-input:focus { background: var(--nx-bg-input); }

.calc-grid-container {
  flex: 1; position: relative; overflow: hidden;
  background: var(--nx-calc-cell-bg);
}
#calc-canvas { position: absolute; inset: 0; cursor: cell; }

.calc-scrollbar-v {
  position: absolute; right: 0; top: 0; bottom: 0; width: 12px;
  background: var(--nx-scrollbar-track);
}
.calc-thumb-v {
  width: 100%; background: var(--nx-scrollbar-thumb);
  border-radius: 6px; min-height: 30px; cursor: pointer;
}
.calc-thumb-v:hover { background: var(--nx-scrollbar-hover); }

.calc-scrollbar-h {
  position: absolute; bottom: 0; left: 0; right: 12px; height: 12px;
  background: var(--nx-scrollbar-track);
}
.calc-thumb-h {
  height: 100%; background: var(--nx-scrollbar-thumb);
  border-radius: 6px; min-width: 30px; cursor: pointer;
}
.calc-thumb-h:hover { background: var(--nx-scrollbar-hover); }

.calc-cell-editor {
  position: absolute; border: 2px solid var(--nx-primary);
  background: var(--nx-calc-cell-bg); font-size: 13px;
  font-family: var(--nx-font-sans); padding: 2px 4px;
  outline: none; z-index: 10; box-shadow: var(--nx-shadow-md);
  color: var(--nx-text-primary); min-width: 60px;
}

.calc-sheet-bar {
  display: flex; align-items: center; background: var(--nx-bg-surface);
  border-top: 1px solid var(--nx-border); height: 32px; padding: 0 4px;
}
.csb-add {
  width: 28px; height: 28px; border-radius: var(--nx-radius-sm);
  background: none; border: none; color: var(--nx-text-secondary);
  cursor: pointer; font-size: 16px; transition: all var(--nx-transition);
}
.csb-add:hover { background: var(--nx-bg-hover); color: var(--nx-text-primary); }
.csb-tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 4px; }
.csb-tabs::-webkit-scrollbar { display: none; }
.csb-tab {
  padding: 4px 12px; border-radius: var(--nx-radius-sm) var(--nx-radius-sm) 0 0;
  background: none; border: none; border-bottom: 2px solid transparent;
  color: var(--nx-text-secondary); cursor: pointer; font-size: 13px;
  transition: all var(--nx-transition); white-space: nowrap;
}
.csb-tab:hover { background: var(--nx-bg-hover); color: var(--nx-text-primary); }
.csb-tab.active {
  color: var(--nx-primary); border-bottom-color: var(--nx-primary);
  background: var(--nx-bg-active);
}

/* ── NexMind Panel ── */
.nexmind-panel {
  width: var(--nx-nexmind-width); min-width: var(--nx-nexmind-width);
  background: var(--nx-bg-surface); border-left: 1px solid var(--nx-border);
  display: flex; flex-direction: column; z-index: 50;
}
.nm-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; border-bottom: 1px solid var(--nx-border);
}
.nm-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--nx-text-primary);
}
.nm-close {
  background: none; border: none; color: var(--nx-text-secondary);
  cursor: pointer; padding: 4px; border-radius: var(--nx-radius-sm);
  transition: all var(--nx-transition);
}
.nm-close:hover { background: var(--nx-bg-hover); color: var(--nx-text-primary); }

.nm-chat {
  flex: 1; overflow-y: auto; padding: 16px;
}
.nm-welcome-msg {
  background: var(--nx-bg-elevated); border-radius: var(--nx-radius-lg);
  padding: 16px; font-size: 14px; line-height: 1.6;
}
.nm-welcome-msg ul { margin: 8px 0; padding-left: 20px; }
.nm-welcome-msg li { margin: 4px 0; color: var(--nx-text-secondary); }

.nm-msg {
  margin-bottom: 12px; animation: fadeInUp 0.3s ease;
}
.nm-msg-user {
  text-align: right;
}
.nm-msg-user .nm-msg-bubble {
  background: var(--nx-primary); color: white;
  display: inline-block; padding: 8px 14px; border-radius: var(--nx-radius-lg) var(--nx-radius-lg) var(--nx-radius-sm) var(--nx-radius-lg);
  max-width: 85%; text-align: left; font-size: 14px; line-height: 1.5;
}
.nm-msg-ai .nm-msg-bubble {
  background: var(--nx-bg-elevated); color: var(--nx-text-primary);
  display: inline-block; padding: 8px 14px; border-radius: var(--nx-radius-sm) var(--nx-radius-lg) var(--nx-radius-lg) var(--nx-radius-lg);
  max-width: 85%; font-size: 14px; line-height: 1.5;
}

.nm-input-area {
  border-top: 1px solid var(--nx-border); padding: 8px;
}
.nm-suggestions {
  display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px;
}
.nm-suggestion {
  padding: 4px 10px; border-radius: var(--nx-radius-full);
  background: var(--nx-bg-elevated); border: 1px solid var(--nx-border);
  color: var(--nx-text-secondary); cursor: pointer; font-size: 12px;
  transition: all var(--nx-transition);
}
.nm-suggestion:hover {
  background: var(--nx-bg-active); color: var(--nx-text-primary);
  border-color: var(--nx-primary);
}
.nm-input-row { display: flex; gap: 4px; }
.nm-input {
  flex: 1; resize: none; padding: 8px 12px; background: var(--nx-bg-input);
  border: 1px solid var(--nx-border); border-radius: var(--nx-radius-md);
  color: var(--nx-text-primary); font-size: 14px; font-family: var(--nx-font-sans);
  outline: none; max-height: 100px;
}
.nm-input:focus { border-color: var(--nx-primary); }
.nm-send {
  width: 36px; height: 36px; border-radius: var(--nx-radius-md);
  background: var(--nx-primary); border: none; color: white;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: background var(--nx-transition);
}
.nm-send:hover { background: var(--nx-primary-light); }

/* ── Status Dock ── */
.status-dock {
  height: var(--nx-statusdock-height);
  background: var(--nx-bg-surface);
  border-top: 1px solid var(--nx-border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; font-size: 12px; color: var(--nx-text-secondary);
}
.sd-left, .sd-center, .sd-right { display: flex; align-items: center; gap: 8px; }
.sd-separator { color: var(--nx-border); }
.sd-module { font-weight: 500; color: var(--nx-primary); }

.sd-ai-status { display: flex; align-items: center; gap: 6px; }
.ai-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--nx-success); }

.sd-lang {
  padding: 2px 6px; background: var(--nx-bg-elevated);
  border-radius: var(--nx-radius-sm); font-size: 11px; font-weight: 500;
}
.sd-zoom { display: flex; align-items: center; gap: 4px; }
.sd-zoom-btn {
  background: none; border: none; color: var(--nx-text-secondary);
  cursor: pointer; padding: 2px 4px; font-size: 14px; border-radius: 2px;
}
.sd-zoom-btn:hover { background: var(--nx-bg-hover); color: var(--nx-text-primary); }
.sd-zoom-val { font-size: 11px; min-width: 35px; text-align: center; }
.sd-zoom-range {
  width: 60px; -webkit-appearance: none; height: 3px;
  background: var(--nx-border); border-radius: 2px; outline: none;
}
.sd-zoom-range::-webkit-slider-thumb {
  -webkit-appearance: none; width: 10px; height: 10px;
  background: var(--nx-primary); border-radius: 50%; cursor: pointer;
}

/* ══════════════════════════════
   COMMAND PALETTE
   ══════════════════════════════ */
.command-palette {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 15vh;
}
.cp-backdrop {
  position: absolute; inset: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
}
.cp-dialog {
  position: relative; width: 560px; max-height: 60vh;
  background: var(--nx-bg-surface); border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-lg); box-shadow: var(--nx-shadow-xl);
  overflow: hidden; animation: fadeInUp 0.15s ease;
}
.cp-search {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  border-bottom: 1px solid var(--nx-border);
}
.cp-search svg { color: var(--nx-text-tertiary); flex-shrink: 0; }
.cp-search input {
  flex: 1; background: none; border: none; color: var(--nx-text-primary);
  font-size: 16px; outline: none;
}
.cp-search kbd {
  padding: 2px 6px; background: var(--nx-bg-elevated); border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-sm); font-size: 11px; color: var(--nx-text-tertiary);
  font-family: var(--nx-font-mono);
}
.cp-results { overflow-y: auto; max-height: calc(60vh - 52px); padding: 4px; }
.cp-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border-radius: var(--nx-radius-md); cursor: pointer;
  transition: background var(--nx-transition);
}
.cp-item:hover, .cp-item.selected { background: var(--nx-bg-hover); }
.cp-item-icon {
  width: 28px; height: 28px; border-radius: var(--nx-radius-sm);
  background: var(--nx-bg-elevated); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; color: var(--nx-text-secondary);
  font-size: 14px;
}
.cp-item-text { flex: 1; min-width: 0; }
.cp-item-title { font-size: 14px; color: var(--nx-text-primary); }
.cp-item-desc { font-size: 12px; color: var(--nx-text-tertiary); margin-top: 1px; }
.cp-item-shortcut {
  font-size: 11px; color: var(--nx-text-tertiary);
  font-family: var(--nx-font-mono); display: flex; gap: 4px;
}
.cp-item-shortcut kbd {
  padding: 1px 5px; background: var(--nx-bg-elevated); border: 1px solid var(--nx-border);
  border-radius: 3px;
}
.cp-empty {
  text-align: center; padding: 32px; color: var(--nx-text-tertiary);
}

/* ══════════════════════════════
   QUICK RING (Radial Menu)
   ══════════════════════════════ */
.quick-ring {
  position: fixed; z-index: 9500;
  width: 220px; height: 220px;
  pointer-events: none;
}
.quick-ring.visible { pointer-events: auto; }
.qr-center {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--nx-bg-elevated); border: 2px solid var(--nx-primary);
  display: flex; align-items: center; justify-content: center;
  color: var(--nx-primary); z-index: 2;
}
.qr-item {
  position: absolute; width: 44px; height: 44px; border-radius: 50%;
  background: var(--nx-bg-surface); border: 1px solid var(--nx-border);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s ease;
  box-shadow: var(--nx-shadow-md); color: var(--nx-text-secondary);
}
.qr-item:hover {
  background: var(--nx-primary); color: white;
  transform: scale(1.15); border-color: var(--nx-primary);
}
.qr-label {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: -20px; font-size: 11px; color: var(--nx-text-primary);
  background: var(--nx-bg-overlay); padding: 2px 6px;
  border-radius: var(--nx-radius-sm); white-space: nowrap;
  opacity: 0; transition: opacity 0.15s; pointer-events: none;
}
.qr-item:hover .qr-label { opacity: 1; }

/* ══════════════════════════════
   NOTIFICATIONS
   ══════════════════════════════ */
.notifications {
  position: fixed; bottom: 40px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; pointer-events: none;
}
.notification {
  padding: 10px 16px; border-radius: var(--nx-radius-md);
  background: var(--nx-bg-surface); border: 1px solid var(--nx-border);
  box-shadow: var(--nx-shadow-lg); font-size: 13px; color: var(--nx-text-primary);
  display: flex; align-items: center; gap: 8px; pointer-events: auto;
  animation: slideInRight 0.3s ease; max-width: 320px;
}
.notification.success { border-left: 4px solid var(--nx-success); }
.notification.error { border-left: 4px solid var(--nx-danger); }
.notification.info { border-left: 4px solid var(--nx-info); }
.notification.warning { border-left: 4px solid var(--nx-warning); }
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .flow-panel { width: 200px; min-width: 200px; }
  .nexmind-panel { width: 280px; min-width: 280px; }
  .writer-page { width: 100%; min-height: auto; padding: 16px; }
}
@media (max-width: 600px) {
  .flow-panel { position: absolute; left: 0; top: var(--nx-voicebar-height); bottom: var(--nx-statusdock-height); z-index: 200; }
  .nexmind-panel { position: absolute; right: 0; top: var(--nx-voicebar-height); bottom: var(--nx-statusdock-height); z-index: 200; }
  .vb-voice-status .voice-text { display: none; }
}

/* ── Print ── */
@media print {
  .voice-bar, .flow-panel, .nexmind-panel, .status-dock,
  .writer-toolbar, .calc-toolbar, .calc-formula-bar, .calc-sheet-bar,
  .command-palette, .quick-ring, .notifications { display: none !important; }
  .writer-scroll { padding: 0; background: white; }
  .writer-page { box-shadow: none; width: 100%; padding: 20mm; }
  .writer-content { color: black; }
}

/* ── Dropdown Menus ── */
.dropdown-menu {
  position: absolute;
  background: var(--nx-bg-surface);
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-md);
  box-shadow: var(--nx-shadow-lg);
  padding: 4px;
  z-index: 1000;
  min-width: 180px;
  animation: fadeInUp 0.15s ease;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--nx-radius-sm);
  cursor: pointer;
  font-size: 13px;
  color: var(--nx-text-primary);
  transition: background var(--nx-transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.dropdown-item:hover { background: var(--nx-bg-hover); }
.dropdown-divider { height: 1px; background: var(--nx-border); margin: 4px 0; }

/* ── Chart container in Calc ── */
.calc-chart-overlay {
  position: absolute;
  background: var(--nx-bg-surface);
  border: 1px solid var(--nx-border);
  border-radius: var(--nx-radius-md);
  box-shadow: var(--nx-shadow-lg);
  padding: 16px;
  z-index: 20;
  min-width: 400px;
  min-height: 300px;
}
.calc-chart-overlay .chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.calc-chart-overlay .chart-title {
  font-size: 14px;
  font-weight: 600;
}
.calc-chart-overlay .chart-close {
  background: none;
  border: none;
  color: var(--nx-text-secondary);
  cursor: pointer;
  font-size: 18px;
}

/* ── Loading/typing indicator ── */
.typing-indicator {
  display: flex; gap: 4px; padding: 8px 14px;
}
.typing-indicator span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--nx-text-tertiary);
  animation: typingBounce 1.2s infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* ── Install PWA Banner ── */
.install-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--nx-bg-surface);
  border: 1px solid var(--nx-primary);
  border-radius: var(--nx-radius-lg);
  padding: 12px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--nx-shadow-xl);
  z-index: 9998;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translate(-50%, 100%); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.install-banner button {
  padding: 6px 16px;
  border-radius: var(--nx-radius-md);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all var(--nx-transition);
}
.install-banner .install-btn {
  background: var(--nx-primary);
  color: white;
}
.install-banner .install-btn:hover { background: var(--nx-primary-light); }
.install-banner .dismiss-btn {
  background: none;
  color: var(--nx-text-secondary);
}
