@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+TC:wght@300;400;500;700&family=Noto+Serif+TC:wght@400;500;600;700&display=swap');

:root {
    --primary-color: #CA8A04;
    /* Gold */
    --primary-hover: #A16207;
    --ink-color: #1C1917;
    --ink-secondary: #44403C;
    --paper-color: #FAFAF9;
    --stone-color: #E7E5E4;
    --border-radius: 12px;
    --sidebar-width: 360px;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.3);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    scrollbar-width: thin;
    scrollbar-color: var(--stone-color) transparent;
}

*::-webkit-scrollbar {
    width: 6px;
}

*::-webkit-scrollbar-track {
    background: transparent;
}

*::-webkit-scrollbar-thumb {
    background-color: var(--stone-color);
    border-radius: 10px;
}

body {
    font-family: 'Noto Sans TC', -apple-system, sans-serif;
    background-color: #D6D3D1;
    /* Slate/Stone background for contrast */
    color: var(--ink-color);
    height: 100vh;
    display: flex;
    overflow: hidden;
}

.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar with Glassmorphism */
.sidebar {
    width: var(--sidebar-width);
    background: var(--glass-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 16px;
    overflow-y: auto;
    z-index: 10;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    margin-bottom: 32px;
    text-align: center;
}

.sidebar-header h1 {
    font-size: 24px;
    color: var(--ink-color);
    font-weight: 700;
    font-family: 'Noto Serif TC', serif;
    letter-spacing: 1px;
    position: relative;
    display: inline-block;
}

.sidebar-header h1::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 20%;
    right: 20%;
    height: 3px;
    background: var(--primary-color);
    border-radius: 2px;
}

.control-group {
    margin-bottom: 24px;
    background: rgba(255, 255, 255, 0.4);
    padding: 12px;
    border-radius: var(--border-radius);
    border: 1px solid var(--glass-border);
}

.control-group:last-child {
    margin-top: auto;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.control-group h3 {
    font-size: 13px;
    color: var(--ink-secondary);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 700;
}

.preview-area {
    flex: 1;
    display: flex;
    overflow: auto;
    background-color: #57534E;
    /* Dark stone */
    background-image:
        radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.05) 1px, transparent 0);
    background-size: 40px 40px;
    padding: 40px;
}

.canvas-wrapper {
    background: white;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4);
    line-height: 0;
    padding: 0;
    margin: auto;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.canvas-wrapper:hover {
    box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5);
}

canvas {
    display: block;
    margin: 0 auto;
}

/* Premium Buttons */
.btn {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    gap: 10px;
    letter-spacing: 0.5px;
}

.btn-primary {
    background-color: var(--ink-color);
    color: var(--paper-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn-primary:hover {
    background-color: var(--ink-secondary);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.btn-success {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 4px 12px rgba(202, 138, 4, 0.3);
}

.btn-success:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(202, 138, 4, 0.4);
}

.icon-btn {
    background: white;
    border: 1px solid var(--stone-color);
    border-radius: 6px;
    cursor: pointer;
    padding: 8px;
    font-size: 16px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ink-secondary);
}

.icon-btn:hover {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
}

/* Premium Settings Layout */
.setting-item {
    margin-bottom: 20px;
}

.setting-item:last-child {
    margin-bottom: 4px;
}

.setting-item>label:first-child {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.setting-item label a {
    text-transform: none;
    letter-spacing: 0;
    font-weight: 500;
    text-decoration: none;
    padding: 2px 6px;
    background: #fee2e2;
    color: #ef4444 !important;
    border-radius: 4px;
    transition: all 0.2s;
}

.setting-item label a:hover {
    background: #fecaca;
    transform: translateY(-1px);
}

/* Premium Upload Button */
.upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 16px;
    background: #fcfcf9;
    border: 1.5px dashed #d1d5db;
    border-radius: 10px;
    color: var(--ink-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.upload-btn:hover {
    background: white;
    border-color: var(--primary-color);
    border-style: solid;
    color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(183, 143, 81, 0.12);
}

.upload-btn svg {
    width: 18px;
    height: 18px;
    opacity: 0.5;
    transition: all 0.25s;
}

.upload-btn:hover svg {
    opacity: 1;
    color: var(--primary-color);
    transform: translateY(-1px);
}

.file-input {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

/* Form Controls */
input[type="number"],
input[type="text"],
select {
    width: 100%;
    padding: 10px;
    margin-bottom: 12px;
    background: white;
    border: 1px solid var(--stone-color);
    border-radius: 8px;
    font-size: 14px;
    color: var(--ink-color);
    transition: border-color 0.2s;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(202, 138, 4, 0.1);
}

label {
    display: block;
    font-size: 12px;
    color: var(--ink-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

/* Theme Items */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
}

.theme-item {
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.3s ease;
    border: 2px solid transparent !important;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.theme-item:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

/* Styled Details */
details {
    margin-bottom: 12px;
    border: 1px solid var(--stone-color);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.3);
    overflow: hidden;
    transition: all 0.3s;
}

details[open] {
    background: rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

summary {
    outline: none;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    padding: 12px;
    color: var(--ink-color);
    list-style: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

summary::after {
    content: '+';
    font-size: 18px;
    color: var(--primary-color);
    transition: transform 0.3s;
}

details[open] summary::after {
    transform: rotate(45deg);
}

.setting-group {
    padding: 0 8px 8px 8px;
}

.setting-group-inner {
    background: white;
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 12px;
    border: 1px solid var(--stone-color);
}

.setting-group h4 {
    font-size: 11px;
    margin-bottom: 10px;
    color: var(--ink-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--stone-color);
    padding-bottom: 6px;
    margin-top: 8px;
}

.setting-row {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 10px;
    min-width: 0;
}

.setting-row label {
    flex: 0 0 95px;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0;
    white-space: nowrap;
}

.setting-row input,
.setting-row select {
    flex: 1;
    min-width: 0;
    padding: 8px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    background: white;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-color);
    outline: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    height: 38px;
}

.setting-row input:focus,
.setting-row select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(183, 143, 81, 0.08);
}

.setting-row input[type="color"] {
    padding: 4px;
    width: 44px;
    flex: 0 0 44px;
    cursor: pointer;
}

/* Remove number input arrows for a cleaner look */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    appearance: none;
    margin: 0;
}

input[type="number"] {
    -moz-appearance: textfield;
    appearance: textfield;
}

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--stone-color);
    border-radius: 3px;
    cursor: pointer;
    flex: 1;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    background: var(--primary-color);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}


.checkbox-row {
    margin-top: 4px;
    padding-left: 90px;
    /* 80px label + 10px gap */
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.checkbox-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-row input[type="checkbox"] {
    width: 14px;
    height: 14px;
    margin: 0;
    cursor: pointer;
}

@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        position: fixed;
        bottom: 0;
        left: 0;
        height: 60vh;
        border-right: none;
        border-top: 1px solid var(--glass-border);
    }

    .preview-area {
        height: 40vh;
    }
}