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

:root {
    --background: 0 0% 9%;
    --foreground: 0 0% 95%;
    --card: 0 0% 11%;
    --card-foreground: 0 0% 95%;
    --popover: 0 0% 11%;
    --popover-foreground: 0 0% 95%;
    --primary: 0 0% 98%;
    --primary-foreground: 0 0% 9%;
    --secondary: 0 0% 15%;
    --secondary-foreground: 0 0% 98%;
    --muted: 0 0% 15%;
    --muted-foreground: 0 0% 64%;
    --accent: 0 0% 15%;
    --accent-foreground: 0 0% 98%;
    --destructive: 0 62.8% 50.6%;
    --destructive-foreground: 0 0% 98%;
    --border: 0 0% 20%;
    --input: 0 0% 20%;
    --ring: 0 0% 83.1%;
    --success: 142 76% 36%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

header {
    background: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
    padding: 20px 24px;
}

header h1 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.025em;
}

header p {
    color: hsl(var(--muted-foreground));
    font-size: 13px;
}

.main-content {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 0;
    flex: 1;
    overflow: hidden;
}

.left-panel {
    background: hsl(var(--card));
    border-right: 1px solid hsl(var(--border));
    overflow-y: auto;
    padding: 24px;
}

.right-panel {
    background: hsl(var(--background));
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section {
    margin-bottom: 24px;
}

.section:last-child {
    margin-bottom: 0;
}

.section-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
    color: hsl(var(--foreground));
    letter-spacing: -0.01em;
}

label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 8px;
    color: hsl(var(--foreground));
}

input[type="text"],
input[type="text"]:focus,
select {
    width: 100%;
    padding: 9px 12px;
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
    font-size: 13px;
    color: hsl(var(--foreground));
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    transition: all 0.15s;
    outline: none;
}

select {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    cursor: pointer;
}

input[type="text"]:hover,
select:hover {
    border-color: hsl(var(--muted-foreground));
}

input[type="text"]:focus,
select:focus {
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 1px hsl(var(--ring));
}

input[type="text"].invalid {
    border-color: hsl(var(--destructive));
}

.error-message {
    color: hsl(var(--destructive));
    font-size: 12px;
    margin-top: 6px;
    display: none;
}

.error-message.show {
    display: block;
}

.control-group {
    margin-bottom: 16px;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 0;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    border-radius: 3px;
    accent-color: hsl(var(--primary));
}

.checkbox-wrapper label {
    margin: 0;
    cursor: pointer;
    font-size: 13px;
    color: hsl(var(--foreground));
}

button {
    background: hsl(var(--primary));
    color: hsl(var(--primary-foreground));
    border: none;
    padding: 9px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

button:hover {
    opacity: 0.9;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover {
    background: hsl(var(--accent));
}

.btn-danger {
    background: hsl(var(--destructive));
    color: hsl(var(--destructive-foreground));
    font-size: 12px;
    padding: 6px 12px;
}

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

.replacements-section {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid hsl(var(--border));
}

.preset-selector {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 16px;
}

.preset-selector>div {
    flex: 1;
}

.preset-selector button {
    white-space: nowrap;
}

.group-section {
    background: hsl(var(--background));
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}

.group-header {
    font-weight: 600;
    margin-bottom: 10px;
    color: hsl(var(--muted-foreground));
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.mapping-table thead {
    border-bottom: 1px solid hsl(var(--border));
}

.mapping-table th {
    padding: 8px 8px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mapping-table td {
    padding: 6px 8px;
    border-bottom: 1px solid hsl(var(--border) / 0.5);
}

.mapping-table tbody tr:last-child td {
    border-bottom: none;
}

.mapping-table input {
    padding: 6px 8px;
    font-size: 12px;
    background: hsl(var(--card));
}

.add-mapping-btn {
    margin-top: 8px;
    width: 100%;
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.preview-header {
    background: hsl(var(--card));
    border-bottom: 1px solid hsl(var(--border));
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stats {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: hsl(var(--muted-foreground));
}

.stat strong {
    color: hsl(var(--foreground));
    margin-right: 4px;
}

.actions {
    display: flex;
    gap: 8px;
}

.table-container {
    flex: 1;
    overflow: auto;
}

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

.files-table thead {
    position: sticky;
    top: 0;
    background: hsl(var(--card));
    z-index: 10;
    border-bottom: 1px solid hsl(var(--border));
}

.files-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 12px;
    color: hsl(var(--muted-foreground));
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.files-table td {
    padding: 12px 16px;
    border-bottom: 1px solid hsl(var(--border) / 0.5);
    font-size: 13px;
}

.files-table tbody tr:hover {
    background: hsl(var(--card) / 0.5);
}

.filename {
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    color: hsl(var(--foreground));
}

.new-filename {
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    color: hsl(var(--success));
    font-weight: 500;
}

.no-change {
    color: hsl(var(--muted-foreground));
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: hsl(var(--muted-foreground));
    padding: 40px;
    text-align: center;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.3;
}

.empty-state h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: hsl(var(--foreground));
}

.empty-state p {
    font-size: 13px;
}

.folder-info {
    background: hsl(var(--secondary));
    border: 1px solid hsl(var(--border));
    border-radius: 6px;
    padding: 12px;
    font-size: 12px;
    color: hsl(var(--muted-foreground));
    margin-top: 12px;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    display: none;
}

.folder-info.show {
    display: block;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: hsl(var(--background));
}

::-webkit-scrollbar-thumb {
    background: hsl(var(--border));
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: hsl(var(--muted-foreground));
}

a {
    color: white;
    text-decoration: none;
    font-weight: 500;
}

a:hover {
    text-decoration: underline;
}

.preview-cell {
    width: 80px;
    text-align: center;
    padding: 8px;
}

.preview-cell img {
    max-width: 60px;
    max-height: 60px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid hsl(var(--border));
    display: block;
    margin: 0 auto;
}

.preview-placeholder {
    width: 60px;
    height: 60px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: hsl(var(--secondary));
    border-radius: 4px;
    border: 1px solid hsl(var(--border));
    font-size: 24px;
    opacity: 0.5;
}

.image-preview-hover {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    border: 2px solid hsl(var(--border));
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    background: hsl(var(--background));
    padding: 4px;
    display: none;
}

.image-preview-hover img {
    display: block;
    max-width: 50vw;
    max-height: 50vh;
    width: auto;
    height: auto;
    border-radius: 4px;
}

.preview-cell img {
    cursor: pointer;
}