/* MarkFeed Modern Responsive Stylesheet */
:root {
  --bg-primary: #0f172a;
  --bg-surface: #1e293b;
  --bg-surface-hover: #334155;
  --bg-input: #0b1120;
  --border-color: #334155;
  --border-focus: #3b82f6;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #3b82f6;
  --accent-hover: #2563eb;
  --accent-light: rgba(59, 130, 246, 0.15);
  --success-color: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning-color: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger-color: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --purple-color: #a855f7;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.5);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Layout */
.app-layout {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 20px 40px;
  width: 100%;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
}

.brand-title-wrap {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-light);
  color: var(--accent-primary);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.brand-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.privacy-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  background: var(--success-bg);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.btn-lang {
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-lang:hover {
  background: var(--border-color);
  border-color: var(--accent-primary);
}

.lang-active {
  color: var(--accent-primary);
}

.lang-sep {
  color: var(--text-muted);
}

/* Sample Bar */
.demo-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.demo-banner strong {
  color: var(--text-primary);
}

.btn-demo {
  background: var(--accent-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s ease;
  white-space: nowrap;
}

.btn-demo:hover {
  background: var(--accent-hover);
}

/* Tabs */
.tabs-container {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.tab-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.tab-btn:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--bg-surface);
  color: var(--accent-primary);
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 1px var(--accent-primary);
}

/* Panels */
.panel-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.panel-section {
  display: none;
}

.panel-section.active {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Paste Area */
.paste-box {
  min-height: 180px;
  max-height: 360px;
  overflow-y: auto;
  background: var(--bg-input);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.2s ease;
}

.paste-box:focus {
  border-color: var(--border-focus);
}

.paste-box:empty::before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.paste-mode-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}

.raw-html-textarea {
  width: 100%;
  min-height: 160px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-primary);
  resize: vertical;
  outline: none;
  line-height: 1.5;
}

.raw-html-textarea:focus {
  border-color: var(--border-focus);
}

/* Drag and Drop Zone */
.drop-zone {
  border: 2px dashed var(--border-color);
  background: var(--bg-input);
  border-radius: var(--radius-lg);
  padding: 36px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--accent-primary);
  background: rgba(59, 130, 246, 0.05);
}

.drop-icon {
  width: 48px;
  height: 48px;
  color: var(--accent-primary);
}

.drop-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.drop-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.file-picked-info {
  display: none;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
}

.file-picked-info.active {
  display: flex;
}

.file-name {
  font-weight: 600;
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.file-size {
  color: var(--text-muted);
  font-size: 12px;
}

/* Inputs & Form Controls */
.form-row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.text-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  width: 100%;
  transition: border-color 0.15s ease;
}

.text-input:focus {
  border-color: var(--border-focus);
}

/* Alerts */
.alert-box {
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  display: none;
}

.alert-box.active {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #fbbf24;
}

.alert-danger {
  background: var(--danger-bg);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #f87171;
}

.alert-info {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  color: #93c5fd;
}

.alert-header {
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-guide {
  font-size: 12px;
  color: var(--text-primary);
}

/* Buttons */
.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.action-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Output Section */
.output-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

.metrics-dashboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.metric-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.metric-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
  margin-top: 2px;
}

.metric-highlight {
  color: var(--accent-primary);
}

.metric-secondary {
  font-size: 11px;
  color: var(--text-secondary);
}

/* Output Toolbar */
.output-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-color);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Split Export Section */
.split-box {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.split-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  font-weight: 600;
}

.split-slider-wrap {
  display: flex;
  align-items: center;
  gap: 14px;
}

.slider-input {
  flex: 1;
  accent-color: var(--accent-primary);
  cursor: pointer;
}

.slider-val-badge {
  background: var(--accent-light);
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  min-width: 90px;
  text-align: center;
}

.chunk-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.chunk-pill {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.chunk-pill.active {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

/* View Container */
.view-container {
  position: relative;
  min-height: 280px;
}

.result-raw {
  width: 100%;
  min-height: 380px;
  max-height: 600px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: #e2e8f0;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.result-preview {
  display: none;
  min-height: 380px;
  max-height: 600px;
  overflow-y: auto;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  color: var(--text-primary);
  line-height: 1.7;
}

.result-preview h1, .result-preview h2, .result-preview h3, .result-preview h4 {
  margin-top: 1.2em;
  margin-bottom: 0.6em;
  font-weight: 700;
  color: #fff;
}

.result-preview h1 { font-size: 1.8em; border-bottom: 1px solid var(--border-color); padding-bottom: 6px; }
.result-preview h2 { font-size: 1.4em; border-bottom: 1px solid var(--border-color); padding-bottom: 4px; }
.result-preview h3 { font-size: 1.2em; }

.result-preview p {
  margin-bottom: 1em;
}

.result-preview ul, .result-preview ol {
  margin-left: 24px;
  margin-bottom: 1em;
}

.result-preview li {
  margin-bottom: 0.3em;
}

.result-preview table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13px;
}

.result-preview th, .result-preview td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.result-preview th {
  background: var(--bg-surface-hover);
  font-weight: 600;
}

.result-preview pre {
  background: #020617;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 1em 0;
}

.result-preview code {
  font-family: var(--font-mono);
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.9em;
}

.result-preview pre code {
  background: transparent;
  padding: 0;
}

.result-preview a {
  color: var(--accent-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.result-preview blockquote {
  border-left: 3px solid var(--accent-primary);
  padding-left: 12px;
  color: var(--text-secondary);
  margin: 1em 0;
}

/* Toast */
.toast-msg {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-surface);
  border: 1px solid var(--accent-primary);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.25s ease;
  z-index: 1000;
}

.toast-msg.show {
  transform: translateY(0);
  opacity: 1;
}

/* Responsive (Mobile width 375px & Tablets) */
@media (max-width: 768px) {
  .app-layout {
    padding: 12px 12px 30px;
    gap: 16px;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .demo-banner {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .form-row {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row {
    flex-direction: column;
    align-items: stretch;
  }

  .action-row .btn-primary, .action-row .btn-secondary {
    width: 100%;
  }

  .output-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-group {
    width: 100%;
    justify-content: space-between;
  }

  .split-slider-wrap {
    flex-direction: column;
    align-items: stretch;
  }
}
