/* ============================================================
   dotdot — Notice Generator Styles
   Color Palette:
   - Charcoal: #1a1a2e
   - Warm Cream: #f5f0e1
   - Golden Orange: #d4a843
   - Coral Pink: #e87d6e
   - Soft White: #fefefe
   - Muted Gray: #8b8b9a
   ============================================================ */

:root {
    /* Core Colors */
    --color-charcoal: #1a1a2e;
    --color-charcoal-light: #252542;
    --color-charcoal-lighter: #2d2d4a;
    --color-cream: #f5f0e1;
    --color-cream-dark: #e8e0cc;
    --color-golden: #d4a843;
    --color-golden-light: #e8c56d;
    --color-golden-dark: #b89038;
    --color-coral: #e87d6e;
    --color-coral-light: #f0a095;
    --color-coral-dark: #d05d4a;
    --color-white: #fefefe;
    --color-white-soft: #faf8f3;
    --color-muted: #8b8b9a;
    --color-muted-light: #a8a8b8;

    /* Semantic Colors */
    --bg-primary: var(--color-cream);
    --bg-secondary: var(--color-white);
    --bg-tertiary: var(--color-cream-dark);
    --bg-card: var(--color-white);
    --bg-hover: var(--color-cream-dark);
    --bg-active: #ddd8cc;

    --text-primary: var(--color-charcoal);
    --text-secondary: #3d3d5c;
    --text-muted: var(--color-muted);
    --text-inverse: var(--color-white);

    --border-color: #e0d8c8;
    --border-focus: var(--color-golden);
    --border-error: var(--color-coral);

    --accent-primary: var(--color-golden);
    --accent-primary-hover: var(--color-golden-dark);
    --accent-secondary: var(--color-coral);
    --accent-secondary-hover: var(--color-coral-dark);

    --shadow-sm: 0 1px 2px rgba(26, 26, 46, 0.06);
    --shadow-md: 0 4px 12px rgba(26, 26, 46, 0.08);
    --shadow-lg: 0 8px 24px rgba(26, 26, 46, 0.1);
    --shadow-xl: 0 16px 40px rgba(26, 26, 46, 0.12);

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    --transition-fast: 120ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    --font-mono: 'Space Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --font-sans: 'DM Sans', 'Noto Sans Devanagari', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-devanagari: 'Noto Sans Devanagari', 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --header-height: 64px;
    --sidebar-width: 280px;
    --sidebar-collapsed: 72px;
}

/* Dark mode support (optional, for later) */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: var(--color-charcoal);
        --bg-secondary: var(--color-charcoal-light);
        --bg-tertiary: var(--color-charcoal-lighter);
        --bg-card: var(--color-charcoal-light);
        --bg-hover: var(--color-charcoal-lighter);
        --bg-active: #3a3a5a;

        --text-primary: var(--color-cream);
        --text-secondary: #d4cebd;
        --text-muted: var(--color-muted-light);
        --text-inverse: var(--color-charcoal);

        --border-color: #3a3a5a;
    }
}

/* ============================================================
   Reset & Base
   ============================================================ */

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: 0.9375rem; /* 15px */
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================================
   Typography
   ============================================================ */

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    font-weight: 600;
    line-height: 1.3;
    color: var(--text-primary);
}

h1 { font-size: clamp(1.75rem, 4vw, 2.5rem); }
h2 { font-size: clamp(1.375rem, 3vw, 1.75rem); }
h3 { font-size: clamp(1.125rem, 2.5vw, 1.375rem); }
h4 { font-size: 1rem; }

p { color: var(--text-secondary); }

a { color: var(--accent-primary); text-decoration: none; }
a:hover { color: var(--accent-primary-hover); text-decoration: underline; }

code, pre {
    font-family: var(--font-mono);
    font-size: 0.875em;
}

::selection {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

/* ============================================================
   Welcome Animation
   ============================================================ */

.intro-overlay {
    position: fixed;
    inset: 0;
    background: var(--color-cream); /* Cream background per reference */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    transition: opacity 0.6s ease, visibility 0.6s ease;
}

.intro-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* Welcome Scene Layout */
.welcome-scene {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    padding: 2rem;
}

/* Typewriter SVG */
.typewriter-svg {
    width: 100%;
    max-width: 360px;
    height: auto;
    transform-origin: center bottom;
}

.typewriter-svg path,
.typewriter-svg circle,
.typewriter-svg line,
.typewriter-svg rect {
    vector-effect: non-scaling-stroke;
}

/* Wordmark Container */
.wordmark-container {
    display: flex;
    align-items: baseline;
    gap: 0.15em;
    margin-top: -0.5rem;
}

.wordmark-text {
    font-family: var(--font-mono);
    font-size: clamp(2rem, 6vw, 3.5rem);
    font-weight: 700;
    color: var(--color-charcoal);
    letter-spacing: -0.02em;
    opacity: 0;
    transform: translateY(10px);
}

.wordmark-dots {
    display: flex;
    gap: 4px;
    margin-left: 0.1em;
}

.wordmark-dots .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    transform: scale(0);
    opacity: 0;
}

.wordmark-dots .dot-1 {
    background: var(--color-golden);
}

.wordmark-dots .dot-2 {
    background: var(--color-coral);
}

/* Tagline */
.welcome-tagline {
    font-family: var(--font-sans);
    font-size: clamp(1rem, 2.5vw, 1.25rem);
    font-weight: 500;
    color: var(--color-muted);
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(10px);
    margin-top: 0.5rem;
}

/* Reduced motion - instant show */
@media (prefers-reduced-motion: reduce) {
    .intro-overlay {
        display: none;
    }
}

/* ============================================================
   App Layout
   ============================================================ */

.app {
    display: grid;
    grid-template-rows: var(--header-height) 1fr;
    grid-template-columns: var(--sidebar-width) 1fr;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Header */
.app-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-brand {
    display: flex;
    align-items: baseline;
    gap: 0.15em;
}

.brand-name {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.brand-dots {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-primary);
    letter-spacing: 0.02em;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
}

.sidebar-header {
    padding: 1.25rem 1rem 0.75rem;
}

.sidebar-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.sections-list {
    list-style: none;
    padding: 0 0.5rem 1rem;
    flex: 1;
    overflow-y: auto;
}

.section-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    border: 1px solid transparent;
}

.section-item:hover {
    background: var(--bg-hover);
}

.section-item.active {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
}

.section-item-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    flex-shrink: 0;
}

.section-item.active .section-item-icon {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

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

.section-item-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.section-item-count {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.section-item-actions {
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.section-item:hover .section-item-actions {
    opacity: 1;
}

.sidebar-empty {
    padding: 2rem 1rem;
    text-align: center;
}

.empty-text {
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.empty-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    padding: 1.5rem;
    overflow-y: auto;
    background: var(--bg-primary);
}

/* Welcome State */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 50vh;
    text-align: center;
    padding: 2rem;
}

.welcome-icon {
    width: 96px;
    height: 96px;
    border-radius: var(--radius-xl);
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    color: var(--text-inverse);
}

.welcome-title {
    margin-bottom: 0.75rem;
}

.welcome-desc {
    max-width: 420px;
    color: var(--text-muted);
    margin-bottom: 2rem;
}

/* Section View */
.section-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.section-header-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.section-title {
    font-family: var(--font-mono);
    font-size: 1.25rem;
    font-weight: 700;
}

.section-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.section-header-actions {
    display: flex;
    gap: 0.5rem;
}

.section-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.125rem;
    font-family: var(--font-sans);
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.4;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

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

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--text-inverse);
    border-color: var(--accent-primary);
}

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

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

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

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--accent-secondary);
    color: var(--text-inverse);
    border-color: var(--accent-secondary);
}

.btn-danger:hover:not(:disabled) {
    background: var(--accent-secondary-hover);
    border-color: var(--accent-secondary-hover);
}

/* ============================================================
   Template List
   ============================================================ */

.template-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.template-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: box-shadow var(--transition-base), border-color var(--transition-base), transform var(--transition-fast);
}

.template-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.template-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.template-card-title {
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

.template-card-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.template-card:hover .template-card-actions {
    opacity: 1;
}

.template-card-meta {
    font-size: 0.8125rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.template-card-fields {
    color: var(--accent-primary);
}

/* ============================================================
   Template Editor
   ============================================================ */

.template-editor {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
}

.editor-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 1rem;
}

.editor-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.editor-title-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.template-name-input {
    font-family: var(--font-sans);
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    background: transparent;
    border: none;
    outline: none;
    padding: 0.25rem 0;
    min-width: 200px;
    max-width: 400px;
}

.template-name-input::placeholder {
    color: var(--text-muted);
}

.template-status {
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
}

.editor-body {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    flex: 1;
    min-height: 0;
}

.editor-pane {
    display: flex;
    flex-direction: column;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 0;
}

.fields-pane {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    height: 100%;
    max-height: 100%;
    position: sticky;
    top: calc(var(--header-height) + 1.5rem + 60px);
}

.pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.pane-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pane-actions {
    display: flex;
    gap: 0.375rem;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    flex-wrap: wrap;
}

.toolbar-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toolbar-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

.toolbar-btn.active,
.toolbar-btn[data-format="insertField"]:hover {
    background: var(--accent-primary);
    color: var(--text-inverse);
    border-color: var(--accent-primary);
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-color);
    margin: 0 0.25rem;
}

.toolbar-btn-text {
    display: none;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.25rem;
}

.toolbar-btn.has-text {
    width: auto;
    padding: 0 0.5rem;
    gap: 0.25rem;
}

.toolbar-btn.has-text .toolbar-btn-text {
    display: inline;
}

.toolbar-btn[data-format="transliteration"].active {
    background: var(--accent-primary);
    color: var(--text-inverse);
    border-color: var(--accent-primary);
}

.toolbar-btn[data-format="transliteration"].active .toolbar-btn-text {
    display: inline;
}

.editor-area {
    flex: 1;
    padding: 1.25rem;
    outline: none;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.7;
    color: var(--text-primary);
    overflow-y: auto;
    min-height: 300px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

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

.editor-area .field-token {
    display: inline-block;
    background: linear-gradient(135deg, rgba(212, 168, 67, 0.15) 0%, rgba(232, 125, 110, 0.15) 100%);
    border: 1px solid rgba(212, 168, 67, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.125rem 0.5rem;
    margin: 0 0.125rem;
    font-family: var(--font-mono);
    font-size: 0.875em;
    color: var(--accent-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    user-select: none;
    white-space: nowrap;
}

.editor-area .field-token:hover {
    background: linear-gradient(135deg, rgba(212, 168, 67, 0.25) 0%, rgba(232, 125, 110, 0.25) 100%);
    border-color: var(--accent-primary);
    transform: scale(1.02);
}

.editor-area .field-token.selected {
    background: var(--accent-primary);
    color: var(--text-inverse);
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.3);
}

.editor-placeholder {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
    text-align: center;
    pointer-events: none;
    padding: 2rem;
}

/* Fields List */
.fields-list {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.fields-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.fields-empty svg {
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.fields-empty p {
    font-weight: 500;
    margin-bottom: 0.25rem;
    color: var(--text-secondary);
}

.fields-empty .hint {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.field-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all var(--transition-fast);
}

.field-item:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-sm);
}

.field-item-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    flex-shrink: 0;
}

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

.field-item-name {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.field-item-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.field-item-actions {
    display: flex;
    gap: 0.25rem;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.field-item:hover .field-item-actions {
    opacity: 1;
}

.field-item-action {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.field-item-action:hover {
    background: var(--bg-hover);
    color: var(--accent-secondary);
    border-color: var(--accent-secondary);
}

.fields-actions {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* ============================================================
   Single Generator
   ============================================================ */

.single-generator {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 720px;
}

.generator-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.generator-title {
    font-family: var(--font-mono);
    font-size: 1.125rem;
}

.generator-body {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.fields-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.field-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.field-input-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.field-input-label .field-badge {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    background: rgba(212, 168, 67, 0.15);
    color: var(--accent-primary);
}

.field-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.field-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.15);
}

.field-input::placeholder {
    color: var(--text-muted);
}

.generator-actions {
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: 1rem;
}

/* Notice Preview */
.notice-preview {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.preview-title {
    font-size: 0.875rem;
    font-weight: 600;
}

.preview-content {
    padding: 1.5rem;
    font-family: var(--font-sans);
    line-height: 1.7;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 50vh;
    overflow-y: auto;
}

/* ============================================================
   Bulk Generator
   ============================================================ */

.bulk-generator {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 900px;
}

.excel-upload-area {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-base);
    background: var(--bg-card);
}

.upload-zone:hover,
.upload-zone.drag-active {
    border-color: var(--accent-primary);
    background: rgba(212, 168, 67, 0.05);
}

.upload-zone:focus-visible {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.15);
}

.upload-icon {
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.upload-text {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.upload-hint {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.excel-preview {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.excel-preview .preview-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.preview-count {
    font-size: 0.8125rem;
    color: var(--text-muted);
}

.excel-table-container {
    max-height: 40vh;
    overflow: auto;
}

.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.excel-table th,
.excel-table td {
    padding: 0.625rem 0.875rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.excel-table th {
    position: sticky;
    top: 0;
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
    z-index: 1;
}

.excel-table tr:hover td {
    background: var(--bg-hover);
}

.excel-table .mismatch-cell {
    background: rgba(232, 125, 110, 0.1);
    color: var(--accent-secondary);
}

.excel-mismatch {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: rgba(232, 125, 110, 0.08);
    border-top: 1px solid rgba(232, 125, 110, 0.2);
    color: var(--accent-secondary);
    font-size: 0.8125rem;
}

/* Bulk Progress */
.bulk-progress {
    padding: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-top: 1rem;
}

.progress-bar {
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    text-align: center;
}

/* ============================================================
   Modals
   ============================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 46, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
}

.modal-overlay:not([hidden]) {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-base);
    box-shadow: var(--shadow-xl);
}

.modal-overlay:not([hidden]) .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-tertiary);
}

.canvas-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
}

.canvas-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(var(--border-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.1;
    pointer-events: none;
}

.canvas-element {
    position: absolute;
    box-sizing: border-box;
    transition: box-shadow var(--transition-fast);
}

.canvas-element.selected {
    box-shadow: 0 0 0 2px var(--accent-primary), var(--shadow-md);
    z-index: 10;
}

.canvas-element.dragging {
    opacity: 0.8;
    box-shadow: var(--shadow-lg);
}

.canvas-text {
    padding: 0.25rem 0.5rem;
    box-sizing: border-box;
    min-height: 1.5em;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent-primary);
    border: 2px solid var(--bg-card);
    border-radius: 2px;
    cursor: se-resize;
    z-index: 20;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast);
}

.resize-handle:hover {
    transform: scale(1.2);
}

.resize-nw { top: -6px; left: -6px; cursor: nw-resize; }
.resize-ne { top: -6px; right: -6px; cursor: ne-resize; }
.resize-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.resize-se { bottom: -6px; right: -6px; cursor: se-resize; }
.resize-n  { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-s  { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-e  { top: 50%; right: -6px; transform: translateY(-50%); cursor: e-resize; }
.resize-w  { top: 50%; left: -6px; transform: translateY(-50%); cursor: w-resize; }

.text-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.text-toolbar-input {
    width: 60px;
    padding: 0.375rem 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.text-toolbar-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.15);
}

.text-toolbar-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.text-toolbar-color {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
}

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

.text-toolbar-color::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-sm);
}

.text-toolbar-select {
    padding: 0.375rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.text-toolbar-select:focus {
    outline: none;
    border-color: var(--border-focus);
}

.inline-text-edit {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 1.5em;
    padding: 0.25rem 0.5rem;
    border: 2px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    color: inherit;
    background: var(--bg-card);
    box-sizing: border-box;
    resize: none;
    outline: none;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

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

.paste-zone-text {
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin: 0;
}

.paste-zone-text kbd {
    display: inline-block;
    padding: 0.125rem 0.375rem;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.paste-zone-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin: 0;
}

.canvas-hint {
    font-size: 0.8125rem;
    color: var(--text-muted);
    font-style: italic;
}

.canvas-grid {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: 
        linear-gradient(var(--border-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--border-color) 1px, transparent 1px);
    background-size: 20px 20px;
    opacity: 0.1;
    pointer-events: none;
}

.canvas-element {
    position: absolute;
    box-sizing: border-box;
    transition: box-shadow var(--transition-fast);
}

.canvas-element.selected {
    box-shadow: 0 0 0 2px var(--accent-primary), var(--shadow-md);
    z-index: 10;
}

.canvas-element.dragging {
    opacity: 0.8;
    box-shadow: var(--shadow-lg);
}

.canvas-text {
    padding: 0.25rem 0.5rem;
    box-sizing: border-box;
    min-height: 1.5em;
}

.resize-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: var(--accent-primary);
    border: 2px solid var(--bg-card);
    border-radius: 2px;
    cursor: se-resize;
    z-index: 20;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-fast);
}

.resize-handle:hover {
    transform: scale(1.2);
}

.resize-nw { top: -6px; left: -6px; cursor: nw-resize; }
.resize-ne { top: -6px; right: -6px; cursor: ne-resize; }
.resize-sw { bottom: -6px; left: -6px; cursor: sw-resize; }
.resize-se { bottom: -6px; right: -6px; cursor: se-resize; }
.resize-n  { top: -6px; left: 50%; transform: translateX(-50%); cursor: n-resize; }
.resize-s  { bottom: -6px; left: 50%; transform: translateX(-50%); cursor: s-resize; }
.resize-e  { top: 50%; right: -6px; transform: translateY(-50%); cursor: e-resize; }
.resize-w  { top: 50%; left: -6px; transform: translateY(-50%); cursor: w-resize; }

.text-toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.text-toolbar-input {
    width: 60px;
    padding: 0.375rem 0.5rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.text-toolbar-input:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(212, 168, 67, 0.15);
}

.text-toolbar-unit {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.text-toolbar-color {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: 0;
}

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

.text-toolbar-color::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-sm);
}

.text-toolbar-select {
    padding: 0.375rem 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color var(--transition-fast);
}

.text-toolbar-select:focus {
    outline: none;
    border-color: var(--border-focus);
}

.inline-text-edit {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    min-height: 1.5em;
    padding: 0.25rem 0.5rem;
    border: 2px solid var(--accent-primary);
    border-radius: var(--radius-sm);
    font-family: inherit;
    color: inherit;
    background: var(--bg-card);
    box-sizing: border-box;
    resize: none;
    outline: none;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

/* Template Header Preview (in editor) */
.template-header-preview {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
    margin-bottom: 1rem;
}

.template-header-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-color);
}

.template-header-preview-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.template-header-preview-content {
    min-height: 80px;
    padding: 0.75rem;
    background: var(--bg-secondary);
}

/* .template-header-preview-content img rule removed - v3 preview uses inline styles with aspect-ratio container */

/* Responsive */
@media (max-width: 480px) {
    .modal {
        max-width: 100%;
        margin: 0.5rem;
    }
}

/* Modal Form */
.modal-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-input,
.form-textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    font-family: var(--font-sans);
    font-size: 1rem;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.15);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: var(--font-sans);
}

/* ============================================================
   Toasts
   ============================================================ */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    z-index: 2000;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 280px;
    max-width: 420px;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
}

.toast.success {
    border-left: 4px solid var(--accent-primary);
}

.toast.error {
    border-left: 4px solid var(--accent-secondary);
}

.toast.warning {
    border-left: 4px solid var(--accent-primary);
}

.toast.info {
    border-left: 4px solid var(--color-muted);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(100%); }
    to { opacity: 1; transform: translateX(0); }
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    margin-top: 0.125rem;
}

.toast.success .toast-icon { color: var(--accent-primary); }
.toast.error .toast-icon { color: var(--accent-secondary); }
.toast.warning .toast-icon { color: var(--accent-primary); }
.toast.info .toast-icon { color: var(--color-muted); }

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.125rem;
}

.toast-message {
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.toast-close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 1024px) {
    .editor-body {
        grid-template-columns: 1fr;
    }

    .fields-pane {
        position: static;
        max-height: none;
        order: -1;
    }

    .fields-actions {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .fields-actions .btn {
        flex: 1;
        min-width: 140px;
    }
}

@media (max-width: 768px) {
    .app {
        grid-template-columns: 1fr;
        grid-template-rows: var(--header-height) auto 1fr;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: var(--header-height);
        bottom: 0;
        width: var(--sidebar-width);
        z-index: 200;
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        box-shadow: var(--shadow-lg);
        border-right: none;
    }

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

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(26, 26, 46, 0.4);
        z-index: 150;
    }

    .sidebar-overlay.open {
        display: block;
    }

    .main-content {
        padding: 1rem;
    }

    .section-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .editor-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .template-name-input {
        max-width: none;
    }

    .modal {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
}

@media (max-width: 480px) {
    .btn-lg {
        padding: 0.75rem 1.25rem;
    }

    .welcome-icon {
        width: 72px;
        height: 72px;
    }

    .intro-text {
        font-size: 2.5rem;
    }
}

/* ============================================================
   Authentication Screen
   ============================================================ */

.auth-screen {
    position: fixed;
    inset: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
    overflow-y: auto;
}

.auth-container {
    width: 100%;
    max-width: 420px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 2.5rem 2rem;
    box-shadow: var(--shadow-xl);
    text-align: center;
}

.auth-header {
    margin-bottom: 2rem;
}

.auth-brand {
    display: flex;
    align-items: baseline;
    gap: 0.15em;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.auth-title {
    font-family: var(--font-mono);
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.auth-body {
    margin-bottom: 1.5rem;
}

.google-signin-button {
    margin-bottom: 1.5rem;
}

.google-signin-button > div {
    width: 100% !important;
}

.signin-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 2rem;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 0.9375rem;
    margin: 0;
}

.auth-privacy {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    text-align: left;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.auth-privacy svg {
    flex-shrink: 0;
    margin-top: 0.125rem;
    color: var(--accent-primary);
}

.auth-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

.auth-version {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin: 0;
}

/* User Info in Header */
.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-right: 1rem;
    padding-right: 1rem;
    border-right: 1px solid var(--border-color);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .auth-card {
        padding: 2rem 1.5rem;
        border-radius: var(--radius-lg);
    }

    .user-info {
        margin-right: 0.5rem;
        padding-right: 0.5rem;
    }

    .user-name {
        max-width: 100px;
    }
}

@media (max-width: 480px) {
    .auth-screen {
        padding: 1rem;
        align-items: flex-start;
        padding-top: 3rem;
    }

    .auth-card {
        padding: 1.5rem 1.25rem;
    }

    .user-info {
        display: none;
    }
}

/* ============================================================
   Storage Setup Screen
   ============================================================ */

.storage-setup {
    text-align: center;
}

.storage-setup-header {
    margin-bottom: 2rem;
}

.storage-setup-title {
    font-family: var(--font-mono);
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.storage-setup-subtitle {
    color: var(--text-muted);
    font-size: 0.9375rem;
}

.storage-setup-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.storage-option {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1.25rem 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--transition-base);
    text-align: left;
}

.storage-option:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-md);
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

.storage-option:focus-visible {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(212, 168, 67, 0.15);
}

.storage-option:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.storage-option svg {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    color: var(--accent-primary);
    border-radius: var(--radius-md);
    background: rgba(212, 168, 67, 0.1);
    padding: 0.5rem;
    transition: all var(--transition-fast);
}

.storage-option:hover svg {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

.storage-option > div {
    flex: 1;
    min-width: 0;
}

.storage-option strong {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.375rem;
    font-size: 1rem;
}

.storage-option-desc {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.storage-setup-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 0.5rem;
}

/* Responsive for storage setup */
@media (max-width: 480px) {
    .storage-option {
        padding: 1rem 1.25rem;
    }

    .storage-option svg {
        width: 36px;
        height: 36px;
        padding: 0.375rem;
    }

    .storage-option strong {
        font-size: 0.9375rem;
    }

    .storage-option-desc {
        font-size: 0.75rem;
    }
}

[hidden] {
    display: none !important;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================================
   Rich letterhead / pasted content in the Template Editor
   ============================================================ */
.editor-area img {
    max-width: 100%;
    height: auto;
    cursor: pointer;
}

/* In table cells a percentage max-width resolves against the (narrow) cell and stops the column from growing
   to fit the image. Use the A4 content width as an absolute ceiling instead; the resize tool keeps it in bounds. */
.editor-area td img,
.editor-area th img {
    max-width: 602px;
}

.editor-area table {
    border-collapse: collapse;
    max-width: 100%;
}

.editor-area td,
.editor-area th {
    outline: 1px dashed rgba(128, 128, 128, 0.3);
    padding: 2px 4px;
    vertical-align: top;
}

.editor-area ul,
.editor-area ol {
    margin: 0.25em 0 0.25em 1.5em;
    padding: 0;
}

.preview-content [data-dd-rich] {
    white-space: normal;
}

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

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

.template-header-preview-header .btn-sm:not(.btn-icon) {
    margin-left: auto;
    margin-right: 0.25rem;
}

/* Image selection overlay (resize / align / delete) */
.dd-img-overlay {
    position: fixed;
    z-index: 900;
    pointer-events: none;
    outline: 2px solid var(--color-golden-dark);
    box-sizing: border-box;
}

.dd-img-overlay[hidden] {
    display: none;
}

.dd-img-bar {
    position: absolute;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    display: flex;
    gap: 2px;
    padding: 2px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    pointer-events: auto;
}

.dd-img-bar button {
    min-width: 28px;
    height: 26px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.dd-img-bar button:hover {
    background: var(--bg-hover);
}

.dd-img-handle {
    position: absolute;
    width: 12px;
    height: 12px;
    background: var(--color-golden-dark);
    border: 2px solid #fff;
    border-radius: 2px;
    pointer-events: auto;
    box-sizing: border-box;
}

.dd-img-nw { left: -6px; top: -6px; cursor: nwse-resize; }
.dd-img-ne { right: -6px; top: -6px; cursor: nesw-resize; }
.dd-img-sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.dd-img-se { right: -6px; bottom: -6px; cursor: nwse-resize; }