:root {
    --primary: #3b82f6; /* Modern Blue */
    --primary-soft: rgba(59, 130, 246, 0.1);
    --bg-main: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-dim: #64748b;
    --border: #e2e8f0;
    --radius-lg: 32px;
    --radius-md: 20px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Montserrat', sans-serif;
    min-height: 100vh;
    padding: 3rem 1rem;
    display: flex;
    justify-content: center;
}

.app-container {
    width: 100%;
    max-width: 1000px;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

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

.back {
    display: inline-block;
    color: var(--text-dim);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    transition: color 0.15s;
}
.back:hover { color: var(--primary); }

.brand-text {
    font-size: 3rem;
    font-weight: 900;
    color: var(--text-main);
    letter-spacing: -0.05em;
    text-transform: uppercase;
}

.brand-text::after {
    content: '.';
    color: var(--primary);
}

header .subtitle {
    color: var(--text-dim);
    font-size: 1rem;
    font-weight: 500;
    margin-top: 0.5rem;
}

/* Cards & Layout */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

/* Settings Panel */
.settings-panel h2, .url-panel h2 {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 2.5rem;
}

.setting-item {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.setting-item label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.setting-item input, .setting-item select {
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 0.85rem 1.25rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.setting-item input:focus, .setting-item select:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 500;
}

/* Slider */
.slider-container {
    display: flex;
    align-items: center;
    gap: 1rem;
}

input[type="range"] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    background: #e2e8f0;
    border-radius: 4px;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    background: var(--primary);
    border-radius: 50%;
    cursor: pointer;
    border: 4px solid white;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

/* URL Panel */
.url-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.url-col {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.url-col label {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.url-col label .hint {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
}

.url-panel textarea {
    width: 100%;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    padding: 1.25rem;
    color: var(--text-main);
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 160px;
    transition: var(--transition);
}

.url-panel textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.url-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.25rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.url-buttons {
    display: flex;
    gap: 0.75rem;
}

/* Review & Rename table */
.review-panel .section-header {
    align-items: flex-start;
    margin-bottom: 1.75rem;
}

.review-panel .section-header h2 {
    margin-bottom: 0.5rem;
}

.review-panel .section-header .hint {
    max-width: 480px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.url-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.url-table th {
    text-align: left;
    padding: 0.85rem 1.25rem;
    background: #f1f5f9;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-dim);
    position: sticky;
    top: 0;
}

.url-table td {
    padding: 0.65rem 1.25rem;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.url-table tr:first-child td {
    border-top: none;
}

.url-cell {
    color: var(--text-dim);
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.name-cell {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.name-input {
    width: 100%;
    min-width: 160px;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-main);
    transition: var(--transition);
}

.name-input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.ext-suffix {
    color: var(--text-dim);
    font-size: 0.85rem;
    font-weight: 600;
}

.row-actions {
    display: flex;
    gap: 0.4rem;
    justify-content: flex-end;
}

/* Results */
.results-section {
    margin-top: 1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    gap: 1rem;
    flex-wrap: wrap;
}

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

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

.result-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.result-card.is-error {
    border-color: #fecaca;
}

.thumbnail-container {
    width: 100%;
    aspect-ratio: 16/10;
    background: #f1f5f9;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.thumbnail-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.thumb-placeholder {
    color: var(--text-dim);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    padding: 1rem;
}

.thumb-placeholder.is-error { color: #ef4444; }

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

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

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-main);
    margin-bottom: 0.25rem;
    word-break: break-word;
}

.file-url {
    font-size: 0.75rem;
    color: var(--text-dim);
    font-weight: 500;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-meta {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 500;
}

.file-meta .size-old {
    text-decoration: line-through;
    opacity: 0.7;
}

.file-meta .size-new {
    color: var(--primary);
    font-weight: 700;
}

.file-meta .size-savings {
    color: #16a34a;
    font-weight: 700;
}

.file-meta.is-over-budget .size-new {
    color: #ef4444;
}

.status-badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-size: 0.65rem;
    font-weight: 700;
    vertical-align: middle;
    margin-left: 0.4rem;
}

.status-badge.done {
    background: #dcfce7;
    color: #16a34a;
}

.status-badge.over {
    background: #fee2e2;
    color: #ef4444;
}

.status-badge.kept {
    background: #ecfeff;
    color: #0e7490;
}

.error-message {
    font-size: 0.8rem;
    color: #ef4444;
    font-weight: 600;
}

.btn {
    padding: 1rem 2rem;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-family: inherit;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: #e2e8f0;
}

.btn-danger {
    background: #fee2e2;
    color: #ef4444;
}

.btn-danger:hover:not(:disabled) {
    background: #fecaca;
}

.card-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.card-actions .btn {
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-small {
    padding: 0.75rem 1rem;
    font-size: 0.85rem;
    text-decoration: none;
    text-align: center;
}

@media (max-width: 640px) {
    .app-container { padding: 0 1rem; }
    header h1 { font-size: 2rem; }
}
