:root {
    --primary: #007AFF;
    --primary-dark: #0051D5;
    --secondary: #5856D6;
    --success: #34C759;
    --warning: #FF9500;
    --error: #FF3B30;
    --background: #F2F2F7;
    --surface: #FFFFFF;
    --surface-secondary: #F9F9FB;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --text-tertiary: #C7C7CC;
    --separator: rgba(60, 60, 67, 0.12);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Noto Sans', 'Noto Sans Arabic', 'Noto Sans Ethiopic', 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background: var(--background);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.15s ease, color 0.15s ease;
}

html[dir="rtl"] body {
    direction: rtl;
}

html[dir="rtl"] .header-content {
    flex-direction: row-reverse;
}

html[dir="rtl"] .logo {
    flex-direction: row-reverse;
}

html[dir="rtl"] .tool-card,
html[dir="rtl"] .edit-card {
    text-align: right;
}

/* Manual theme override */
html[data-theme="dark"] {
    --background: #000000;
    --surface: #1C1C1E;
    --surface-secondary: #2C2C2E;
    --text-primary: #FFFFFF;
    --text-secondary: #8E8E93;
    --text-tertiary: #636366;
    --separator: rgba(84, 84, 88, 0.65);
}

html[data-theme="light"] {
    --background: #F2F2F7;
    --surface: #FFFFFF;
    --surface-secondary: #F9F9FB;
    --text-primary: #000000;
    --text-secondary: #8E8E93;
    --text-tertiary: #C7C7CC;
    --separator: rgba(60, 60, 67, 0.12);
}

#app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

#docx-render-mount.docx-render-mount {
  position: fixed;
  left: -10000px;
  top: 0;
  width: 900px;
  background: transparent;
}

.docx-page {
  width: 794px; /* A4 width at 96dpi */
  min-height: auto; /* Allow content to determine height */
  background: #ffffff;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  overflow: hidden; /* Prevent content overflow */
}

.docx-content {
  padding: 48px;
  color: #111;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.docx-content img {
  max-width: 100%;
  height: auto;
}

.docx-content table {
  width: 100%;
  border-collapse: collapse;
}

.docx-content table th,
.docx-content table td {
  border: 1px solid #ddd;
  padding: 8px;
}

.docx-content h1, .docx-content h2, .docx-content h3,
.docx-content h4, .docx-content h5, .docx-content h6 {
  margin-top: 1em;
  margin-bottom: 0.5em;
}

.docx-content p {
  margin-bottom: 0.8em;
}

.docx-content ul, .docx-content ol {
  margin-left: 1.5em;
  margin-bottom: 0.8em;
}

/* Header */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--separator);
    padding: 16px 20px;
    padding-top: calc(16px + env(safe-area-inset-top, 0));
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    max-width: 600px;
    margin: 0 auto;
}

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

.logo-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 10px;
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
}

.logo-text p {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 400;
}

.menu-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface-secondary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.menu-btn:active {
    transform: scale(0.95);
    background: var(--separator);
}

/* Main Content */
.main-content {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
    padding: 20px;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
}


/* PDF Text Editor */
.pdf-editor-content {
  width: min(980px, calc(100vw - 24px));
  height: min(90vh, 860px);
  padding: 0;
  overflow: hidden;
  position: relative;
}

.pdf-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--separator);
  background: var(--surface);
  flex-wrap: wrap;
}

.pdf-editor-title h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}

.pdf-editor-title p {
  font-size: 12px;
  color: var(--text-secondary);
}

/* Professional Toolbar */
.pdf-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--separator);
  background: var(--surface-secondary);
  flex-wrap: wrap;
}

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

.toolbar-select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--separator);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  min-width: 100px;
}

.toolbar-input {
  width: 60px;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--separator);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  text-align: center;
}

.toolbar-input-sm {
  width: 50px;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--separator);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 13px;
  text-align: center;
}

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

.toolbar-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--separator);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.toolbar-btn:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.toolbar-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.toolbar-color {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--separator);
  padding: 4px;
  cursor: pointer;
}

/* Zoom Bar */
.pdf-zoom-bar {
  padding: 8px 14px;
  border-bottom: 1px solid var(--separator);
  background: var(--surface);
  display: flex;
  justify-content: center;
}

.pdf-zoom-controls {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.pdf-zoom-controls .zoom-btn {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--separator);
  background: var(--surface-secondary);
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pdf-zoom-controls .zoom-select {
  width: 92px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--separator);
  background: var(--surface);
  color: var(--text-primary);
}

.pdf-editor-body {
  height: calc(100% - 180px);
  overflow: auto;
  padding: 14px;
  background: var(--background);
}

.pdf-edit-sheet {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--separator);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.pdf-edit-sheet.active {
  display: flex;
  flex-direction: column;
}

.pdf-edit-sheet-input {
  width: 100%;
  height: 46px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--separator);
  background: var(--surface);
  color: var(--text-primary);
  font-size: 16px;
  font-weight: 500;
  outline: none;
}

.mobile-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
}

.pdf-edit-sheet-actions {
  display: flex;
  gap: 10px;
}

.pdf-editor-content.sheet-open .pdf-editor-body {
  padding-bottom: 180px;
}

.pdf-editor-pages {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.pdf-page {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    overflow: hidden;
}

.pdf-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.pdf-text-layer {
    position: absolute;
    inset: 0;
    pointer-events: none;
    user-select: text;
    -webkit-user-select: text;
    overflow: hidden;
}

.pdf-text-layer span {
    cursor: text;
    pointer-events: auto;
    position: absolute;
    white-space: pre;
    transform-origin: 0% 0%;
    color: transparent !important;
    -webkit-text-fill-color: transparent !important;
    text-shadow: none !important;
}

.pdf-text-layer span::selection {
    background: rgba(0, 122, 255, 0.35);
}

.pdf-text-layer span:hover {
    background: rgba(0, 122, 255, 0.12);
}

.pdf-edit-overlay {
  position: absolute;
  display: flex;
  align-items: center;
  padding: 0 2px;
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.95);
  border-radius: 6px;
  pointer-events: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  z-index: 10;
}

html[data-theme="dark"] .pdf-edit-overlay {
    background: rgba(28, 28, 30, 0.85);
}

.pdf-edit-input {
    position: absolute;
    border: 2px solid rgba(0, 122, 255, 0.7);
    border-radius: 8px;
    padding: 2px 6px;
    font: inherit;
    outline: none;
    background: var(--surface);
    color: var(--text-primary);
}

html[data-theme="dark"] .pdf-edit-input {
    background: var(--surface);
    color: var(--text-primary);
}

.btn.btn-sm {
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 10px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    background: var(--surface-secondary);
    padding: 4px;
    border-radius: var(--radius-lg);
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tab.active {
    background: var(--surface);
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.tab svg {
    opacity: 0.7;
}

.tab.active svg {
    opacity: 1;
}

/* Tab Content */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Section */
.section {
    margin-bottom: 24px;
}

.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* Conversion Grid */
.conversion-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Tool Grid (Sejda-like cards) */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.tool-card {
    background: var(--surface);
    border: 1px solid rgba(0, 0, 0, 0.04);
    border-radius: 18px;
    box-shadow: var(--shadow-md);
    padding: 18px 16px;
    display: flex;
    gap: 14px;
    text-align: left;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.tool-card:active {
    transform: scale(0.985);
    box-shadow: var(--shadow-lg);
}

.tool-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex: 0 0 auto;
}

.tool-icon.blue { background: linear-gradient(135deg, #2F7BFF 0%, #6AA9FF 100%); }
.tool-icon.purple { background: linear-gradient(135deg, #6D5BFF 0%, #8D7CFF 100%); }
.tool-icon.orange { background: linear-gradient(135deg, #FF7A00 0%, #FF9E4A 100%); }
.tool-icon.green { background: linear-gradient(135deg, #00C48C 0%, #2FE3A7 100%); }
.tool-icon.pink { background: linear-gradient(135deg, #FF2D55 0%, #FF5C7A 100%); }
.tool-icon.gray { background: linear-gradient(135deg, #8E8E93 0%, #B0B0B5 100%); }

.tool-badge {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.tool-text h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 2px 0 6px;
    color: var(--text-primary);
}

.tool-text p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.35;
}

.conversion-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.conversion-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
}

.card-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 12px;
    flex-shrink: 0;
}

.card-icon.pdf {
    background: linear-gradient(135deg, #FF3B30 0%, #FF6B5A 100%);
    color: white;
}

.card-icon.docx {
    background: linear-gradient(135deg, #007AFF 0%, #5AC8FA 100%);
    color: white;
}

.card-icon.image {
    background: linear-gradient(135deg, #34C759 0%, #30D158 100%);
    color: white;
}

.card-arrow {
    flex: 1;
    display: flex;
    justify-content: center;
    color: var(--text-tertiary);
}

.card-label {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Edit Grid */
.edit-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.edit-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px 16px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: none;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
}

.edit-icon {
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: var(--radius-lg);
    color: white;
}

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

.edit-desc {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--radius-xl);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--separator);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-secondary);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.close-btn:active {
    background: var(--separator);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.muted {
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.4;
}

.ad-gate-slot {
    margin: 14px 0 10px;
    border-radius: var(--radius-lg);
    background: var(--surface-secondary);
    border: 1px solid var(--separator);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ad-gate-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-align: center;
}

.ad-gate-placeholder {
    height: 84px;
    border-radius: 14px;
    background: rgba(0, 0, 0, 0.04);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    color: var(--text-secondary);
}

.pro-status {
    padding: 12px 14px;
    border-radius: var(--radius-lg);
    background: var(--surface-secondary);
    border: 1px solid var(--separator);
    margin: 12px 0;
    font-size: 13px;
    color: var(--text-primary);
}

.pro-actions {
    display: grid;
    gap: 12px;
}

#ton-connect {
    display: flex;
    width: 100%;
}

#ton-connect > *:not(:first-child) {
    display: none !important;
}

#ton-connect button:not(:first-of-type),
#ton-connect a:not(:first-of-type) {
    display: none !important;
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--separator);
    border-radius: var(--radius-lg);
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.drop-zone:hover,
.drop-zone.dragover {
    border-color: var(--primary);
    background: rgba(0, 122, 255, 0.05);
}

.drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.drop-text {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
}

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

/* File List */
.file-list {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--surface-secondary);
    border-radius: var(--radius-md);
}

.file-item-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: 600;
}

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

.file-item-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.file-item-remove {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--error);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Options Panel */
.options-panel {
    margin-top: 16px;
    padding: 16px;
    background: var(--surface-secondary);
    border-radius: var(--radius-md);
}

.options-title {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-secondary);
}

/* Form Controls */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--separator);
    border-radius: var(--radius-md);
    font-size: 15px;
    background: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

select.form-control {
    color-scheme: light dark;
}

select.form-control option {
    background: var(--surface);
    color: var(--text-primary);
}

html[data-theme="dark"] {
    color-scheme: dark;
}

html[data-theme="light"] {
    color-scheme: light;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

/* Modal Footer */
.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--separator);
}

/* Buttons */
.btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

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

.btn-secondary {
    background: var(--surface-secondary);
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

/* Processing Modal */
.processing-content {
    text-align: center;
    padding: 40px 24px;
}

.processing-animation {
    margin-bottom: 24px;
}

.spinner {
    width: 64px;
    height: 64px;
    margin: 0 auto;
    border: 4px solid var(--separator);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.processing-content h2 {
    font-size: 22px;
    margin-bottom: 8px;
}

.processing-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.progress-bar {
    height: 4px;
    background: var(--separator);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    border-radius: 2px;
    transition: width 0.3s ease;
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Result Modal */
.result-content {
    text-align: center;
    padding: 40px 24px;
}

.result-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.result-icon.success {
    background: linear-gradient(135deg, var(--success) 0%, #30D158 100%);
    color: white;
}

.result-content h2 {
    font-size: 24px;
    margin-bottom: 8px;
}

.result-content p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.result-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--separator);
    display: flex;
    padding: 8px 16px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0));
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.nav-item.active {
    color: var(--primary);
}

/* Ad Container */
.ad-container {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 8px;
    justify-content: center;
    padding: 0;
    pointer-events: auto;
    margin: 16px auto 0;
    width: 100%;
    max-width: 600px;
}

.ad-pill {
    width: min(560px, calc(100vw - 32px));
    margin: 0 auto;
    text-align: center;
    padding: 12px 14px;
    border-radius: 16px;
    background: rgba(0, 122, 255, 0.08);
    color: var(--text-secondary);
    font-size: 13px;
    border: 1px solid rgba(0, 122, 255, 0.08);
}

.ad-banner {
    width: min(560px, calc(100vw - 32px));
    margin: 0 auto;
    text-align: center;
    padding: 14px 16px;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--separator);
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.ad-banner:active {
    transform: scale(0.99);
}

/* Responsive */

/* Extra small devices (phones, 320px and up) */
@media (max-width: 374px) {
    .tool-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .edit-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .tool-card {
        padding: 16px 14px;
    }

    .section-title {
        font-size: 20px;
    }

    .modal-content {
        max-width: 100%;
        margin: 10px;
    }

    .btn {
        padding: 12px 20px;
        font-size: 15px;
    }
}

/* Small devices (phones, 375px and up) */
@media (min-width: 375px) and (max-width: 413px) {
    .tool-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .edit-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Medium devices (large phones, 414px and up) */
@media (min-width: 414px) and (max-width: 767px) {
    .tool-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .edit-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablets and up */
@media (min-width: 768px) {
    .conversion-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
    }

    .edit-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .bottom-nav {
        display: none;
    }

    .main-content {
        padding-bottom: 40px;
    }

    .modal-content {
        max-width: 540px;
    }
}

/* Large tablets and desktops */
@media (min-width: 1024px) {
    .tool-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .edit-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Mobile-specific improvements */
@media (max-width: 767px) {
    /* Improve touch targets */
    .btn, .tab, .nav-item, .tool-card, .edit-card, .conversion-card {
        min-height: 44px;
    }

    .close-btn, .menu-btn {
        min-width: 44px;
        min-height: 44px;
    }

    /* Better modal sizing */
    .modal {
        padding: 10px;
    }

    .modal-content {
        max-height: calc(100vh - 20px);
        border-radius: 16px;
    }

    .modal-body {
        max-height: calc(100vh - 200px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Improve form controls */
    .form-control {
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
    }

    input[type="range"] {
        min-height: 44px;
    }

    /* Better file upload area */
    .drop-zone {
        padding: 30px 15px;
        min-height: 150px;
    }

    /* Improve tabs */
    .tabs {
        gap: 6px;
        padding: 3px;
    }

    .tab {
        padding: 10px 12px;
        font-size: 14px;
    }

    /* Better spacing */
    .main-content {
        padding: 16px;
    }

    .section {
        margin-bottom: 20px;
    }
}

/* PDF Editor mobile improvements */
@media (max-width: 520px) {
    .pdf-editor-content {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }

    .pdf-editor-body {
        padding: 10px;
    }

    .pdf-editor-header {
        gap: 8px;
        padding: 10px 12px;
        flex-wrap: wrap;
    }

    .pdf-editor-title {
        flex: 1 1 100%;
        order: 1;
    }

    .pdf-zoom-controls {
        order: 2;
        flex: 1;
    }

    .pdf-editor-header .btn-sm {
        order: 3;
        min-width: 80px;
    }

    .pdf-edit-sheet {
        padding: 16px;
        gap: 12px;
    }

    .pdf-edit-sheet-input {
        height: 50px;
        font-size: 16px;
    }
}

/* Landscape mode adjustments */
@media (max-width: 767px) and (orientation: landscape) {
    .modal-body {
        max-height: calc(100vh - 150px);
    }

    .drop-zone {
        padding: 20px 15px;
        min-height: 100px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .logo-img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* Improve scrolling on iOS */
.modal-body,
.pdf-editor-body {
    -webkit-overflow-scrolling: touch;
}

/* Better touch feedback */
@media (hover: none) and (pointer: coarse) {
    .btn:active,
    .tool-card:active,
    .edit-card:active,
    .conversion-card:active {
        transform: scale(0.97);
        transition: transform 0.1s ease;
    }

    .tab:active,
    .nav-item:active {
        opacity: 0.7;
    }
}

/* Notch/safe area support */
@supports (padding: max(0px)) {
    .header {
        padding-top: max(16px, env(safe-area-inset-top));
    }

    .bottom-nav {
        padding-bottom: max(8px, env(safe-area-inset-bottom));
    }

    .main-content {
        padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom)));
    }
}

/* Dark Mode */
@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        --background: #000000;
        --surface: #1C1C1E;
        --surface-secondary: #2C2C2E;
        --text-primary: #FFFFFF;
        --text-secondary: #8E8E93;
        --text-tertiary: #636366;
        --separator: rgba(84, 84, 88, 0.65);
        color-scheme: dark;
    }
}
