*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
  border: 0 !important;
  outline: none !important;
}

:root {
  /* Palette copied from logo.svg */
  --bg-canvas: #0B132B;
  --bg-card: #1C2541;
  --bg-surface: #0B132B;
  --bg-surface-hover: #16223F;

  --flat-primary: #00BBF9;
  --flat-primary-hover: #00F5D4;
  --flat-primary-active: #0052D4;

  --flat-secondary: #0052D4;
  --flat-secondary-hover: #00BBF9;

  --flat-success: #00F5D4;
  --flat-success-hover: #00BBF9;

  --flat-danger: #ef4444;
  --flat-danger-hover: #dc2626;

  --text-heading: #ffffff;
  --text-body: #e2e8f0;
  --text-muted: #8fa0bc;
  --text-dim: #5c7094;
}

html,
body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg-card);
  color: var(--text-body);
  border: 0 !important;
  outline: none !important;
  -webkit-text-size-adjust: 100%;
  touch-action: pan-y;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #16223F;
}

/* Blogger Widget Hide */
.section,
.widget,
#navbar-iframe,
.navbar {
  display: none !important;
}

/* App Layout */
.app-layout {
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: row;
  overflow: hidden;
  background: var(--bg-card);
}

/* Sidebar (Desktop Mode: Width > Height) */
.app-sidebar {
  width: 230px;
  min-width: 220px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  padding: 24px 14px;
  gap: 18px;
  flex-shrink: 0;
  box-sizing: border-box;
  border-right: 1px solid rgba(255, 255, 255, 0.06) !important;
  z-index: 100;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}

.sidebar-brand {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-heading);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.3px;
}

.sidebar-close-btn {
  display: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  align-items: center;
  justify-content: center;
}

.sidebar-close-btn:hover {
  color: var(--text-heading);
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  text-align: left;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-heading);
}

.nav-item.active {
  background: var(--bg-card);
  color: var(--flat-primary);
  font-weight: 700;
}

.nav-icon {
  flex-shrink: 0;
}

/* Main Content Area */
.app-main {
  flex: 1 1 0%;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  background: var(--bg-card);
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  position: relative;
}

/* Tab Panels */
.tab-panel {
  display: none;
  width: 100%;
  min-height: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
}

/* Unified Container for all 4 Tabs */
.tab-content-container {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-sizing: border-box;
}

/* Mobile Hamburger & Backdrop */
.mobile-nav-toggle {
  display: none;
  position: fixed;
  top: calc(14px + env(safe-area-inset-top, 0px));
  left: calc(14px + env(safe-area-inset-left, 0px));
  z-index: 1100;
  width: 40px;
  height: 40px;
  background: var(--bg-surface);
  color: var(--text-heading);
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45);
}

.mobile-nav-toggle:hover {
  background: var(--bg-surface-hover);
  color: var(--flat-primary);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(2px);
  z-index: 1150;
}

.sidebar-backdrop.show {
  display: block;
}

/* Header */
.app-header {
  text-align: center;
  padding: 4px 0 2px;
  flex-shrink: 0;
}

.app-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-heading);
  letter-spacing: -0.3px;
}

.app-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 4px;
}

/* Hidden File Inputs */
.file-input-hidden {
  display: none !important;
}

/* Flat Drop Zone (Unified across Video, WebP, Meme) */
.dropzone {
  width: 100%;
  min-height: 140px;
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  text-align: center;
  padding: 24px 18px;
  box-sizing: border-box;
  user-select: none;
  border: 1px dashed rgba(255, 255, 255, 0.12) !important;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dropzone:hover,
.dropzone.drag-active {
  background: var(--bg-surface-hover);
  border-color: var(--flat-primary) !important;
}

.drop-icon {
  width: 40px;
  height: 40px;
  fill: none;
  stroke: var(--flat-primary);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.drop-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
}

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

/* File Info Box */
.file-info-box {
  width: 100%;
  display: none;
  align-items: center;
  gap: 12px;
  background: var(--bg-surface);
  padding: 10px 14px;
  box-sizing: border-box;
}

.file-icon-box {
  width: 36px;
  height: 36px;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--flat-primary);
  flex-shrink: 0;
}

.file-details {
  flex: 1;
  min-width: 0;
}

.file-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-heading);
}

.file-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.remove-file-btn {
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.remove-file-btn:hover {
  color: var(--flat-danger);
}

/* Text Input Area */
.input-box {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.input-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.input-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}

.input-stats {
  font-size: 11px;
  color: var(--text-dim);
}

.qr-textarea {
  width: 100%;
  height: 48px;
  min-height: 48px;
  background: var(--bg-surface);
  color: var(--text-heading);
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
  resize: vertical;
  box-sizing: border-box;
  user-select: text;
}

.qr-textarea:focus {
  background: var(--bg-surface-hover);
}

.qr-textarea::placeholder {
  color: var(--text-dim);
}

/* Settings Grid */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  min-width: 0;
}

.setting-item {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  width: 100%;
}

.setting-item.full-width {
  grid-column: 1 / -1;
}

.setting-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.setting-select {
  background: var(--bg-surface);
  color: var(--text-heading);
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  height: 38px;
  box-sizing: border-box;
}

.setting-select:focus {
  background: var(--bg-surface-hover);
}

/* Color Pickers */
.color-picker-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  padding: 6px 10px;
  height: 38px;
  box-sizing: border-box;
  width: 100%;
}

.color-input {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 26px;
  height: 26px;
  background: none;
  cursor: pointer;
  border: 0 !important;
  padding: 0;
  flex-shrink: 0;
}

.color-input::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-input::-webkit-color-swatch {
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.color-hex-text {
  font-size: 12px;
  font-family: monospace;
  color: var(--text-body);
  flex: 1;
  text-transform: uppercase;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.checkbox-label input {
  accent-color: var(--flat-primary);
  cursor: pointer;
}

/* Cards & Result Boxes (Unified 16px padding & 12px gap) */
.preview-card,
.result-box,
.burik-preview-card {
  background: var(--bg-surface);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.result-box {
  display: none;
}

.preview-meta-bar,
.burik-meta-bar,
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 11px;
  color: var(--text-muted);
}

.result-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--flat-primary);
  display: flex;
  align-items: center;
  gap: 6px;
}

.result-info {
  font-size: 11px;
  color: var(--text-muted);
}

/* Checkerboard Preview Stages */
.preview-stage,
.burik-canvas-wrap,
#webpPreviewContainer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 220px;
  max-height: min(320px, 40vh);
  padding: 12px;
  overflow: hidden;
  background-color: #0B132B;
  background-image:
    linear-gradient(45deg, #16223F 25%, transparent 25%),
    linear-gradient(-45deg, #16223F 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #16223F 75%),
    linear-gradient(-45deg, transparent 75%, #16223F 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  box-sizing: border-box;
}

#qrCanvas,
#burikPreviewCanvas,
#webpImagePreview {
  max-width: 100%;
  max-height: 280px;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

#qrCanvas {
  width: min(240px, 70vw);
  height: min(240px, 70vw);
}

#burikPreviewCanvas {
  width: auto;
  height: auto;
}

/* Empty state */
.preview-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 24px;
}

.preview-placeholder svg {
  width: 36px;
  height: 36px;
  stroke: var(--text-dim);
}

/* Action Buttons (Unified height 40px, flex 1, gap 8px) */
.result-actions {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  width: 100%;
}

.download-btn {
  flex: 1 1 0%;
  min-width: 0;
  height: 40px;
  background: var(--flat-primary);
  color: #0B132B;
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  user-select: none;
  white-space: nowrap;
  box-sizing: border-box;
  transition: background 0.15s ease, color 0.15s ease;
}

.download-btn:hover {
  background: var(--flat-primary-hover);
  color: #0B132B;
}

.download-btn.svg-btn {
  background: #0052D4;
  color: #ffffff;
}

.download-btn.svg-btn:hover {
  background: #00D2FF;
  color: #0B132B;
}

.download-btn:disabled,
.download-btn[disabled] {
  background: var(--bg-surface-hover);
  color: var(--text-dim);
  cursor: not-allowed;
}

.reset-btn {
  flex: 1 1 0%;
  min-width: 0;
  height: 40px;
  background: var(--bg-surface-hover);
  color: var(--text-body);
  padding: 10px 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  user-select: none;
  white-space: nowrap;
  box-sizing: border-box;
  transition: background 0.15s ease, color 0.15s ease;
}

.reset-btn:hover {
  background: #24345c;
  color: var(--text-heading);
}

/* Primary Full-width Convert Button */
.convert-btn {
  width: 100%;
  height: 42px;
  background: var(--flat-primary);
  color: #0B132B;
  padding: 11px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  user-select: none;
  transition: background 0.15s ease;
}

.convert-btn:hover:not(:disabled) {
  background: var(--flat-primary-hover);
  color: #0B132B;
}

.convert-btn:active:not(:disabled) {
  background: var(--flat-primary-active);
}

.convert-btn:disabled {
  background: var(--bg-surface-hover);
  color: var(--text-dim);
  cursor: not-allowed;
}

/* Progress & Status */
.progress-box {
  display: none;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}

.progress-bar-bg {
  height: 8px;
  background: var(--bg-surface);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--flat-primary);
}

.progress-text-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* Audio Player */
audio {
  width: 100%;
  height: 38px;
}

/* Pembuat Meme Styles */
#burikWorkspace {
  display: none;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}

#burikTextSizeGroup {
  display: none;
}

/* Crop Toggle Group */
.crop-toggle-group {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.crop-toggle-btn {
  background: var(--bg-surface);
  color: var(--text-muted);
  padding: 9px 8px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 36px;
  white-space: normal;
  line-height: 1.25;
  user-select: none;
  transition: background 0.15s ease, color 0.15s ease;
}

.crop-toggle-btn:hover {
  background: var(--bg-surface-hover);
  color: var(--text-body);
}

.crop-toggle-btn.active {
  background: var(--flat-primary);
  color: #0B132B;
  font-weight: 700;
}

/* Slider Styles */
.slider-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  width: 100%;
}

.slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
}

.slider-value {
  font-size: 12px;
  font-weight: 700;
  color: var(--flat-primary);
}

.flat-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 36px;
  background: transparent;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  padding: 0;
  margin: 0;
}

.flat-slider::-webkit-slider-runnable-track {
  width: 100%;
  height: 6px;
  background: var(--bg-surface);
  cursor: pointer;
}

.flat-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  background: var(--flat-primary);
  cursor: pointer;
  margin-top: -8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.flat-slider::-webkit-slider-thumb:hover,
.flat-slider:active::-webkit-slider-thumb {
  background: var(--flat-primary-hover);
}

.flat-slider::-moz-range-track {
  width: 100%;
  height: 6px;
  background: var(--bg-surface);
  cursor: pointer;
}

.flat-slider::-moz-range-thumb {
  width: 22px;
  height: 22px;
  background: var(--flat-primary);
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.flat-slider::-moz-range-thumb:hover,
.flat-slider:active::-moz-range-thumb {
  background: var(--flat-primary-hover);
}

/* Toast Notification */
.toast-popup {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--flat-primary);
  color: #0B132B;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.toast-popup.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Portrait / Mobile Mode (Width <= Height) */
@media (max-aspect-ratio: 1/1) {
  .mobile-nav-toggle {
    display: flex;
  }

  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 250px;
    max-width: 80vw;
    z-index: 1200;
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: none;
  }

  .app-sidebar.open {
    transform: translateX(0);
  }

  .sidebar-close-btn {
    display: flex;
  }

  .tab-content-container {
    padding: 58px 14px 36px !important;
    gap: 14px !important;
  }

  .download-btn,
  .reset-btn {
    padding: 9px 4px;
    font-size: 11px;
    gap: 4px;
  }
}

body.mode-portrait .mobile-nav-toggle {
  display: flex;
}

body.mode-portrait .app-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 250px;
  max-width: 80vw;
  z-index: 1200;
  transform: translateX(-100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: none;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.mode-portrait .app-sidebar.open {
  transform: translateX(0);
}

body.mode-portrait .sidebar-close-btn {
  display: flex;
}

body.mode-portrait .tab-content-container {
  padding: calc(58px + env(safe-area-inset-top, 0px)) calc(14px + env(safe-area-inset-right, 0px)) calc(36px + env(safe-area-inset-bottom, 0px)) calc(14px + env(safe-area-inset-left, 0px)) !important;
  gap: 14px !important;
}

body.mode-portrait .download-btn,
body.mode-portrait .reset-btn {
  padding: 9px 4px;
  font-size: 11px;
  gap: 4px;
}