:root {
    --primary: #c5a880; /* 上品なゴールドベージュ */
    --accent: #4a5d4e; /* 深みのあるグリーン（ハンドメイドのナチュラル感） */
    --bg: #fdfcf9;
    --text: #333;
    --text-light: #888;
    --white: #ffffff;
    --shadow: 0 8px 30px rgba(0,0,0,0.08);
    --glass: rgba(255, 255, 255, 0.8);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', 'Noto Sans JP', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    overflow: hidden; /* 防止スクロール */
    height: 100vh;
    display: flex;
    justify-content: center;
}

#app {
    width: 100%;
    max-width: 500px; /* モバイルサイズに最適化 */
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--white);
    position: relative;
}

header {
    padding: 20px;
    text-align: center;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 1px;
}

header h1 span {
    color: var(--primary);
}

header p {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 4px;
}

main {
    flex: 1;
    position: relative;
    padding: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#preview-container {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #f0f0f0;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow);
}

#main-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: move;
}

#empty-state {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-light);
    pointer-events: none;
}

#empty-state .icon {
    font-size: 3rem;
    margin-bottom: 10px;
    opacity: 0.2;
}

#loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

#debug-info {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    background: rgba(255, 230, 230, 0.95);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #ff4444;
    font-size: 0.75rem;
    z-index: 100;
    line-height: 1.4;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

#debug-title {
    font-weight: bold;
    color: #ff4444;
    margin-bottom: 5px;
}

#debug-msg {
    font-family: monospace;
    color: #333;
    word-break: break-all;
    white-space: pre-wrap;
}

.loader {
    width: 40px;
    height: 40px;
    border: 3px solid #eee;
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#controls {
    padding: 20px;
    background: var(--glass);
    backdrop-filter: blur(10px);
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.03);
}

.tab-container {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    background: #f0edeb;
    padding: 4px;
    border-radius: 10px;
}

.tab-btn {
    flex: 1;
    border: none;
    padding: 10px;
    background: transparent;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.3s;
    font-weight: 500;
}

.tab-btn.active {
    background: var(--white);
    color: var(--primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.tab-content {
    display: none;
}

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

.upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 120px;
    border: 2px dashed #ddd;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.3s;
    color: var(--text-light);
}

.upload-label:hover {
    border-color: var(--primary);
    background: #fffafa;
}

.upload-label .plus {
    font-size: 2rem;
    margin-bottom: 5px;
}

.instruction {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 10px;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.preset-item {
    aspect-ratio: 1 / 1;
    background: #eee;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    cursor: pointer;
    border: 2px solid transparent;
}

.preset-item.active {
    border-color: var(--primary);
}

.preset-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.preset-item span {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.5);
    color: white;
    font-size: 0.6rem;
    padding: 2px;
    text-align: center;
}

.custom-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    color: var(--text-light);
}

footer {
    padding: 20px;
}

.primary-btn {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 12px;
    background: var(--primary);
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    box-shadow: 0 4px 15px rgba(197, 168, 128, 0.3);
}

.primary-btn:disabled {
    background: #ddd;
    box-shadow: none;
    cursor: not-allowed;
}

.hidden {
    display: none !important;
}
