:root {
    --bg-color: #fafafa;
    --text-color: #0f0f0f;
    --subtle-text: #666666;

    --input-bg: #ffffff;
    --input-border: #e0e0e0;
    --input-focus: #0f0f0f;

    --primary-color: #0f0f0f;
    --primary-text: #ffffff;

    --card-bg: rgba(255, 255, 255, 0.8);
    --card-border: rgba(255, 255, 255, 0.6);
    --card-shadow: 0 8px 32px rgba(0, 0, 0, 0.04);

    --radius-sm: 6px;
    --radius-md: 12px;

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.app-container {
    max-width: 680px;
    margin: 0 auto;
    padding: 2rem 1rem;
    width: 100%;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-nav {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 2rem;
    margin-bottom: 2.5rem;
    border-bottom: 1px solid #e5e5e5;
    padding-bottom: 0px;
}

.tab-btn {
    background: none;
    border: none;
    padding: 0.75rem 0;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--subtle-text);
    cursor: pointer;
    position: relative;
    transition: color 0.2s ease;
    font-family: inherit;
}

.tab-btn:hover {
    color: var(--text-color);
}

.tab-btn.active {
    color: var(--text-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

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

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.morphism-card {
    background: var(--card-bg);
    border: 1px solid white;
    box-shadow: var(--card-shadow);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-md);
    padding: 2.5rem;
}

.header {
    margin-bottom: 2rem;
    text-align: center;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
    color: var(--text-color);
}

.header p {
    color: var(--subtle-text);
    font-size: 0.95rem;
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.5;
}

.dynamic-field {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 100px;
    opacity: 1;
    transform: translateY(0);
    overflow: hidden;
    margin-bottom: 1.25rem;
}

.dynamic-field.collapsed {
    max-height: 0;
    opacity: 0;
    transform: translateY(-10px);
    margin-bottom: 0;
    padding: 0;
}

.form-section-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-color);
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--input-border);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr 1fr;
        margin-bottom: 0;

    }

    .form-grid .form-group {
        margin-bottom: 1.25rem;
    }
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text-color);
}

input,
select {
    width: 100%;
    padding: 0.75rem 0.85rem;
    font-size: 0.95rem;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    background-color: var(--input-bg);
    color: var(--text-color);
    font-family: inherit;
    transition: all 0.2s ease;
    outline: none;
    appearance: none;
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: "↓";
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8rem;
    color: var(--subtle-text);
    pointer-events: none;
}

input:focus,
select:focus {
    border-color: var(--input-focus);
    box-shadow: 0 0 0 1px rgba(15, 15, 15, 0.1);
}

input::placeholder {
    color: #a0a0a0;
}

/* Document Type Selection (Radio) */
.group-label {
    margin-bottom: 0.75rem;
}

.radio-group {
    display: flex;
    gap: 1rem;
}

.radio-option {
    flex: 1;
    position: relative;
}

.radio-option input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.radio-label {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.75rem;
    background: #f5f5f5;
    /* Slightly different bg for unselected state */
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--subtle-text);
    cursor: pointer;
    transition: all 0.2s ease;
}

.radio-option input:checked~.radio-label {
    background: var(--input-bg);
    border-color: var(--input-focus);
    color: var(--text-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.radio-option:hover .radio-label {
    background: white;
    color: var(--text-color);
}

/* Primary Button */
.btn-primary {
    width: 100%;
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: var(--primary-color);
    color: var(--primary-text);
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.1s ease, background-color 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
}

.btn-primary:hover {
    background-color: #000000;
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.templates-header {
    text-align: center;
    margin-bottom: 3rem;
}

.templates-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.templates-header p {
    color: var(--subtle-text);
    font-size: 0.95rem;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 2rem;
    justify-content: center;
}

.gallery-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.gallery-card {
    background: white;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    width: 100%;
    max-width: 280px;
    aspect-ratio: 210 / 297;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gallery-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}

.gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    user-select: none;
}

.gallery-label {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-color);
}

.btn-primary.loading {
    opacity: 0.8;
    cursor: wait;
}

.templates-footer {
    margin-top: 3rem;
    text-align: center;
    border-top: 1px solid var(--input-border);
    padding-top: 1.5rem;
}

.templates-footer p {
    color: var(--subtle-text);
    font-size: 0.9rem;
}

.templates-footer a {
    color: var(--text-color);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid var(--text-color);
    transition: opacity 0.2s ease;
}

.templates-footer a:hover {
    opacity: 0.7;
}



/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 1000;
}

.toast {
    background: white;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    max-width: 400px;
    transform: translateX(120%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border-left: 4px solid var(--primary-color);
}

.toast.show {
    transform: translateX(0);
}

.toast-icon {
    font-size: 1.25rem;
}

.toast-content {
    flex: 1;
}

.toast-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 2px;
    color: var(--text-color);
}

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

.toast.success {
    border-left-color: #10B981;
}

.toast.error {
    border-left-color: #EF4444;
}

.toast.info {
    border-left-color: var(--primary-color);
}

@media (max-width: 480px) {
    .toast-container {
        left: 20px;
        right: 20px;
        bottom: 20px;
    }

    .toast {
        min-width: unset;
        width: 100%;
    }
}