/* CSS Variables - KOKUMIN Brand & Glassmorphism */
:root {
    --color-bg-dark: #0f172a;
    --color-kokumin-yellow: #f5b500;
    --color-kokumin-blue: #043e80;
    --color-deep-blue: #003366;
    --color-kokumin-red: #E60012;
    --color-white: #ffffff;

    --glass-bg: rgba(30, 30, 35, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-blur: 20px;
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);

    --spacing-safe-bottom: env(safe-area-inset-bottom, 20px);
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans JP', sans-serif;
    background-color: var(--color-bg-dark);
    color: white;
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

#app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* --- Top Bar (New Header) --- */
#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    height: 60px;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border);
    z-index: 200;
}

.header-left,
.header-right {
    display: flex;
    gap: 8px;
}

.header-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: rgba(255, 255, 255, 0.8);
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.header-btn:active {
    background: rgba(255, 255, 255, 0.15);
    transform: scale(0.96);
}

.header-btn span.material-symbols-rounded {
    font-size: 20px;
}

/* --- Canvas Area --- */
#canvas-area {
    flex: 65;
    position: relative;
    background-color: #333;
    background-image:
        linear-gradient(45deg, #2a2a2a 25%, transparent 25%),
        linear-gradient(-45deg, #2a2a2a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #2a2a2a 75%),
        linear-gradient(-45deg, transparent 75%, #2a2a2a 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Floating Undo Button */
.floating-undo {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 150;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-undo:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.floating-undo:active {
    transform: scale(0.95);
}

.floating-undo span {
    font-size: 24px;
}

#canvas-wrapper {
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    touch-action: none;
}

/* SNS Guide Overlay */
#guide-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 5;
    border: 1px dashed rgba(255, 255, 255, 0.3);
}

.guide-line {
    position: absolute;
    background: rgba(255, 255, 255, 0.1);
}

.guide-line.center-x {
    width: 1px;
    height: 100%;
    left: 50%;
}

.guide-line.center-y {
    height: 1px;
    width: 100%;
    top: 50%;
}

/* Layer Tab Styling - ULTRA COMPACT */
.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.03);
    padding: 2px 12px;
    /* Ultra-tight padding */
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    width: 100%;
    cursor: pointer;
}

.layer-item.active {
    background: rgba(245, 181, 0, 0.15);
    border-left: 3px solid var(--color-kokumin-yellow);
}

.layer-info {
    flex: 1;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.layer-actions {
    display: flex;
    gap: 4px;
}

.layer-action-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
}

.layer-action-btn:active {
    color: var(--color-kokumin-yellow);
}

/* UI Panel (Glassmorphism) */
#ui-panel {
    flex: 35;
    background: var(--glass-bg);
    backdrop-filter: blur(var(--glass-blur));
    border-top: 1px solid var(--glass-border);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
    border-radius: 24px 24px 0 0;
    display: flex;
    flex-direction: column;
    padding: 8px 0 0 0;
    /* Minimized top padding */
    z-index: 100;
}

.panel-section.sliders.hidden {
    display: none;
}

.panel-section.sliders {
    padding: 0 24px;
    margin-bottom: 10px;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px;
}

.slider-group label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    width: 90px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.slider-group label span.material-symbols-rounded {
    font-size: 16px;
    opacity: 0.8;
}

.slider-val {
    margin-left: auto;
    color: var(--color-kokumin-yellow);
    font-weight: bold;
    font-variant-numeric: tabular-nums;
}

input[type=range] {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
}

input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    background: var(--color-kokumin-yellow);
    cursor: pointer;
    margin-top: -7px;
}

input[type=range]::-webkit-slider-runnable-track {
    width: 100%;
    height: 3px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

/* Asset Scroll */
.panel-section.assets-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0 24px;
    scrollbar-width: none;
}

.panel-section.assets-scroll.layer-mode {
    padding: 0;
}

.panel-section.assets-scroll::-webkit-scrollbar {
    display: none;
}

.asset-track {
    display: flex;
    gap: 12px;
}

.asset-track.layer-mode {
    gap: 0;
}

.asset-item {
    min-width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.preview-text {
    font-weight: 900;
    font-size: 12px;
    text-align: center;
    transform: skewX(-10deg);
}

.style-blue {
    color: var(--color-kokumin-blue);
    text-shadow: 1px 1px 0 white, -1px -1px 0 white, 1px -1px 0 white, -1px 1px 0 white;
}

.style-white {
    color: white;
    text-shadow: 1px 1px 0 var(--color-kokumin-blue), -1px -1px 0 var(--color-kokumin-blue), 1px -1px 0 var(--color-kokumin-blue), -1px 1px 0 var(--color-kokumin-blue);
}

.style-red {
    background: var(--color-kokumin-red);
    color: white;
    padding: 3px 6px;
    border-radius: 3px;
}

/* 3. Bottom Nav */
.bottom-nav {
    display: flex;
    justify-content: space-around;
    padding: 8px 0 calc(8px + var(--spacing-safe-bottom)) 0;
    background: var(--color-deep-blue);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-item {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.6);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    font-size: 9px;
    cursor: pointer;
}

.nav-item.active {
    color: var(--color-white);
}

.nav-item span.material-symbols-rounded,
.nav-item .nav-icon-wrapper {
    font-size: 22px;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px;
    border-radius: 14px;
    width: 36px;
    height: 36px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.nav-item.active span.material-symbols-rounded,
.nav-item.active .nav-icon-wrapper {
    background: var(--color-kokumin-yellow);
    color: var(--color-bg-dark);
}

.usagi-nav-icon img {
    width: 24px;
    height: 24px;
}

.glass-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
    border-radius: 99px;
    padding: 6px 18px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    line-height: 1;
}

.glass-btn.primary {
    background: var(--color-kokumin-yellow);
    color: var(--color-bg-dark);
    border: none;
    box-shadow: 0 4px 15px rgba(245, 181, 0, 0.2);
}

.glass-btn:active {
    transform: scale(0.96);
}

.glass-btn span.material-symbols-rounded {
    font-size: 20px;
}