
:root {
    --bg-dark: #0f1014;
    --sidebar-bg: rgba(24, 24, 27, 0.85); /* Glassmorphism effect */
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
    --panel-radius: 12px;
    --danger: #ef4444;
    --transition-speed: 0.2s;
    --font-main: 'Inter', 'Noto Sans JP', sans-serif;
    --shadow-premium: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
    --top-bar-height: 56px;
    --sidebar-width: 300px;
}

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

body {
    background-color: var(--bg-dark);
    background-image: 
        radial-gradient(circle at 2px 2px, rgba(255, 255, 255, 0.05) 1px, transparent 0),
        radial-gradient(circle at 50% 50%, rgba(99, 102, 241, 0.02) 0%, transparent 60%);
    background-size: 20px 20px, 100% 100%;
    color: var(--text-primary);
    font-family: var(--font-main);
    overflow: hidden;
    height: 100vh;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: rgba(15, 16, 20, 0.95);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
    letter-spacing: -0.025em;
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.top-actions {
    display: flex;
    gap: 12px;
}

/* Sidebar & Main */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Sidebars */
.sidebar {
    width: var(--sidebar-width);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
}

#sidebar-info {
    display: none;
}

.right-sidebar {
    border-right: none;
    border-left: 1px solid var(--border-color);
}

.panel {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--panel-radius);
    padding: 14px;
    box-shadow: var(--shadow-premium);
}

.panel h3 {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* Canvas Viewport */
.canvas-viewport {
    flex: 1;
    padding: 40px;
    background: transparent;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: grab;
}

.canvas-viewport:active {
    cursor: grabbing;
}

.canvas-container {
    position: relative;
    width: 100%;
    height: 100%;
    min-height: 500px;
    overflow: hidden;
}

.canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    transform-origin: top left;
}

.bg-img-layer {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0.4;
    pointer-events: none;
    z-index: 1;
    transform-origin: top left;
}

.wall-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    transform-origin: top left;
    overflow: visible;
}

.vertex-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 20;
    transform-origin: top left;
}

/* Buttons and Controls */
.btn {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-speed);
    font-family: inherit;
    text-align: center;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: rgba(255, 255, 255, 0.1); color: var(--text-primary); }
.btn-danger { background: rgba(239, 68, 68, 0.1); color: #fca5a5; border: 1px solid rgba(239, 68, 68, 0.2); }

.top-actions .btn {
    width: auto;
}

.shape-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.shape-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
}

.shape-btn:hover {
    background: rgba(74, 158, 255, 0.1);
    border-color: var(--accent);
}

.shape-btn .icon {
    font-size: 1.5rem;
}

/* Inputs */
.input-group {
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.input-group input, 
.input-group select,
.input-group textarea {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.875rem;
}

.input-group textarea {
    resize: vertical;
    min-height: 60px;
}

/* Mobile Navigation */
.mobile-nav {
    display: none;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 8px;
    gap: 8px;
    z-index: 110; /* Above sidebars if needed */
}

.nav-btn {
    flex: 1;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.nav-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Mobile Instruction List */
.mobile-instr-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mobile-instr-list li {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.mobile-instr-list li span {
    color: var(--accent);
    font-weight: bold;
    margin-right: 8px;
    min-width: 60px;
}

/* Property Panel Utilities */
.color-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.color-chip {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid rgba(255, 255, 255, 0.1);
    transition: transform 0.2s, border-color 0.2s;
}

.color-chip:hover {
    transform: scale(1.1);
}

.color-chip.active {
    border-color: white;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
}

/* Furniture Objects */
.furniture-obj {
    position: absolute;
    opacity: 0.85;
    transition: box-shadow var(--transition-speed), border var(--transition-speed);
    cursor: move;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-weight: bold;
    font-size: 0.75rem;
    user-select: none;
    border: 2px solid rgba(255, 255, 255, 0.2);
}

.furniture-obj.selected {
    opacity: 1;
    border: 3px solid #fff;
    box-shadow: 0 0 0 4px var(--accent), 0 0 20px var(--accent);
    z-index: 100 !important;
}

.furniture-obj .name-label {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 8px;
    border-radius: 4px;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 4px;
}

.lock-svg {
    display: inline-block;
    width: 1em;
    height: 1em;
}

/* Vertex Points */
.vertex-dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: #fff;
    border: 3px solid var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    cursor: move;
    z-index: 30;
    pointer-events: auto;
}

.vertex-dot:hover {
    background: var(--accent);
    scale: 1.2;
}

/* Selection Marquee */
.selection-marquee {
    position: fixed;
    border: 1px dashed var(--accent);
    background: rgba(74, 158, 255, 0.1);
    pointer-events: none;
    z-index: 1000;
    display: none;
}

/* Markers */
.origin-marker {
    display: none;
}

.origin-label {
    display: none;
}

/* Utilities */
.info-text {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.help-msg {
    color: var(--text-secondary);
    font-size: 0.8rem;
    text-align: center;
    padding: 40px 20px;
}

.zoom-controls {
    position: absolute;
    bottom: 24px;
    right: 24px;
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    padding: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.zoom-controls button {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
}

.zoom-controls span {
    padding: 0 12px;
    font-size: 0.8rem;
    min-width: 60px;
    text-align: center;
}

/* Markdown Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--sidebar-bg);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.markdown-body {
    padding: 32px;
    overflow-y: auto;
    color: var(--text-primary);
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    html, body {
        overflow-y: auto !important; /* Force vertical scroll */
        height: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    #app {
        height: auto;
        min-height: 100vh;
        overflow: visible;
    }

    .top-bar {
        padding: 10px 16px;
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .top-actions {
        width: 100%;
        justify-content: space-between;
    }

    .mobile-nav {
        display: flex;
        position: sticky;
        top: 0;
        backdrop-filter: blur(10px);
    }

    .main-content {
        flex-direction: column;
        overflow: visible;
        height: auto;
    }

    .sidebar {
        width: 100%;
        border: none;
        display: none; /* Hidden by default on mobile */
        padding: 16px;
        background: var(--bg-dark);
        min-height: 400px;
    }

    .sidebar.active {
        display: flex;
    }

    #sidebar-info {
        display: none;
    }

    #sidebar-info.active {
        display: flex;
    }

    .right-sidebar {
        border-left: none;
        border-top: 1px solid var(--border-color);
    }

    .canvas-viewport {
        padding: 20px;
        min-height: 350px;
        display: none; /* Hidden by default on mobile unless active */
        background: var(--bg-dark);
    }

    .canvas-viewport.active {
        display: flex;
    }

    .canvas-container {
        transform: scale(0.85); /* Scale down for smaller screens */
        transform-origin: center top;
        margin: 0 auto;
    }

    /* Adjust inputs for touch */
    .input-group input, 
    .input-group select,
    .btn {
        min-height: 44px; /* Standard touch target size */
    }

    .shape-btn {
        padding: 16px;
    }

    .logo h1 {
        font-size: 1.1rem;
    }
}

/* PC Operations Instructions (Fixed Floor Panel) */
.pc-instructions {
    position: fixed;
    bottom: 0;
    right: 0;
    background: rgba(15, 16, 20, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-right: none;
    border-bottom: none;
    border-radius: 12px 0 0 0;
    padding: 0;
    font-size: 11px;
    color: var(--text-secondary);
    z-index: 200;
    box-shadow: var(--shadow-premium);
    width: 300px;
    transition: all 0.3s ease;
}

.pc-instructions-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    pointer-events: auto;
}

.pc-instructions-header:hover h4 {
    color: var(--accent);
}

.pc-instructions h4 {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    transition: color 0.2s;
}

.toggle-icon {
    font-size: 8px;
    transition: transform 0.3s;
    opacity: 0.5;
}

.pc-instructions-content {
    padding: 0 20px 20px 20px;
    overflow-y: auto;
    max-height: 500px;
    transition: all 0.3s ease;
}

.pc-instructions.collapsed .pc-instructions-content {
    padding-bottom: 0;
    max-height: 0;
    overflow: hidden;
}

.pc-instructions.collapsed .toggle-icon {
    transform: rotate(-180deg);
}

.instr-group {
    margin-bottom: 12px;
}

.instr-group:last-child {
    margin-bottom: 0;
}

.instr-group h5 {
    color: var(--accent);
    font-size: 9px;
    margin-bottom: 6px;
    border-bottom: 1px solid rgba(99, 102, 241, 0.2);
    padding-bottom: 3px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.pc-instructions-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pc-instructions-content li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: var(--text-secondary);
}

.pc-instructions-content li span {
    color: var(--text-primary);
    opacity: 0.8;
    font-weight: 500;
}

@media (max-width: 768px) {
    #pc-instructions {
        display: none !important;
    }
}

/* README Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 800px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.1rem;
    color: var(--accent);
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: white;
}

.markdown-body {
    padding: 24px;
    overflow-y: auto;
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 0.95rem;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
    color: var(--text-primary);
    margin-top: 24px;
    margin-bottom: 12px;
}

.markdown-body h1 {
    font-size: 1.5rem;
}

.markdown-body h2 {
    font-size: 1.25rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 8px;
}

.markdown-body p {
    margin-bottom: 16px;
}

.markdown-body ul {
    margin-bottom: 16px;
    padding-left: 20px;
}

.markdown-body li {
    margin-bottom: 8px;
}

.markdown-body strong {
    color: var(--accent);
}

.markdown-body hr {
    border: none;
    border-bottom: 1px solid var(--border-color);
    margin: 24px 0;
}
