body {
    font-family: 'Noto Sans JP', sans-serif;
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: #f4f4f4;
    overflow: hidden;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.1rem 0.3rem;
    background-color: #fff;
    border-bottom: 1px solid #ddd;
    position: relative;
    min-height: 35px;
    flex-shrink: 0;
}

header h1 { font-size: 24px; margin: 0; font-weight: 600; }
#hamburger-btn { display: none; background: none; border: none; cursor: pointer; padding: 0; z-index: 1001; }
#hamburger-btn span { display: block; width: 25px; height: 3px; background-color: #333; margin: 5px 0; transition: 0.3s; }
#nav-menu { display: flex; gap: 0.15rem; }
main { flex-grow: 1; overflow: hidden; }
.container { display: flex; height: 100%; }

.control-panel {
    width: 120px;
    padding: 1rem;
    background-color: #fff;
    border-right: 1px solid #2F3E46;
    overflow-y: auto;
    box-sizing: border-box;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.add-item-btn {
    padding: 0.4rem 0.8rem;
    border: 2px solid #2F3E46;
    border-radius: 8px;
    background: #F4F3EE;
    color: #2F3E46;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.add-item-btn:hover {
    background: #2F3E46;
    color: #F4F3EE;
}

.control-section { margin-bottom: 0.7rem; padding: 0.7rem; background: #F4F3EE; border: 2px solid #2F3E46; border-radius: 12px; }
.control-section h2 { font-size: 0.8rem; margin-top: 0; margin-bottom: 0.5rem; color: #2F3E46; font-weight: 600; border-bottom: 2px solid #2F3E46; padding-bottom: 0.4rem; }
textarea, select { width: 100%; padding: 0.5rem 0.8rem; margin-bottom: 0.4rem; border: 2px solid #2F3E46; border-radius: 8px; background: #F4F3EE; color: #2F3E46; font-size: 12px; box-sizing: border-box; }
textarea:focus, select:focus { outline: none; border-color: #2F3E46; background: #FFFFFF; box-shadow: 0 0 0 3px rgba(47, 62, 70, 0.1); }
button { padding: 0.4rem 0.8rem; border: 2px solid #2F3E46; border-radius: 8px; background: #F4F3EE; color: #2F3E46; cursor: pointer; font-size: 12px; font-weight: 600; }
button:hover { background: #2F3E46; color: #F4F3EE; }

.svg-container { flex-grow: 1; overflow: auto; }
#model-svg { width: 100%; height: 100%; }

/* --- Logic Model Specific Styles --- */
.column-bg { fill: #fdfdfd; stroke: #f0f0f0; stroke-width: 1px; }
.column-title { font-size: 18px; font-weight: bold; fill: #2F3E46; text-transform: uppercase; letter-spacing: 1px; }

.logic-card { 
    cursor: pointer; 
    transition: all 0.2s ease;
}

.logic-card:hover .card-rect {
    stroke: #000;
    stroke-width: 4px;
    filter: drop-shadow(0px 4px 8px rgba(0,0,0,0.2));
}

.logic-card:hover .connection-point-out,
.logic-card:hover .connection-point-in {
    opacity: 0.8 !important;
    r: 5;
}

.logic-card.selected-for-connection .card-rect {
    stroke: #ff006e;
    stroke-width: 4px;
    stroke-dasharray: 8 4;
    animation: pulse 1s infinite;
}

.logic-card.connectable-target .card-rect {
    stroke: #00A86B !important;
    stroke-width: 4px !important;
    filter: drop-shadow(0px 0px 8px rgba(0,168,107,0.5));
    animation: connectable-pulse 1.5s ease-in-out infinite;
}

.logic-card.selected-for-connection .connection-point-out {
    opacity: 1 !important;
    fill: #ff006e;
    animation: pulse-point 1s infinite;
}

@keyframes pulse {
    0% { stroke-opacity: 1; }
    50% { stroke-opacity: 0.5; }
    100% { stroke-opacity: 1; }
}

@keyframes connectable-pulse {
    0%, 100% { 
        filter: drop-shadow(0px 0px 8px rgba(0,168,107,0.5));
        transform: scale(1);
    }
    50% { 
        filter: drop-shadow(0px 0px 12px rgba(0,168,107,0.8));
        transform: scale(1.02);
    }
}

@keyframes pulse-point {
    0% { r: 4; opacity: 1; }
    50% { r: 6; opacity: 0.7; }
    100% { r: 4; opacity: 1; }
}

.card-rect {
    stroke: #000;
    stroke-width: 3px;
    rx: 12; ry: 12;
    transition: all 0.2s ease;
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.1));
}

.card-text-container { 
    pointer-events: none; 
}

.card-text-div, 
foreignObject div,
.logic-card foreignObject div { 
    padding: 12px !important; 
    font-size: 12px !important; 
    color: #fff !important; 
    font-weight: 700 !important;
    line-height: 1.3 !important; 
    text-align: center !important; 
    display: flex !important; 
    justify-content: center !important; 
    align-items: center !important; 
    height: 100% !important; 
    width: 100% !important;
    box-sizing: border-box !important;
    word-break: break-word !important; 
    pointer-events: none !important;
}

path.connection {
    fill: none !important;
    stroke: #000 !important;
    stroke-width: 2px !important;
    stroke-linejoin: round;
    opacity: 0.8;
    transition: all 0.2s ease;
    cursor: pointer;
}

path.connection:hover {
    stroke: #000 !important;
    stroke-width: 3px !important;
    opacity: 1;
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.3));
}

/* --- Responsive & Modal Styles --- */
@media (max-width: 768px) { 
    .container { flex-direction: column; } 
    .control-panel { 
        width: 100%; 
        height: 60px;
        flex-direction: row;
        justify-content: center;
        border-right: none; 
        border-bottom: 1px solid #2F3E46; 
        padding: 0.5rem;
    } 
    #hamburger-btn { display: block; } 
    #nav-menu { 
        position: absolute; 
        top: 100%; 
        right: 0; 
        background-color: white; 
        border: 1px solid #ddd; 
        flex-direction: column; 
        padding: 0.5rem; 
        transform: translateY(-150%); 
        transition: transform 0.3s ease-in-out; 
        z-index: 1000; 
    } 
    #nav-menu.active { transform: translateY(0); } 
}
.modal { display: none; position: fixed; z-index: 1000; left: 0; top: 0; width: 100%; height: 100%; background-color: rgba(47, 62, 70, 0.5); backdrop-filter: blur(4px); }
.modal-content { background-color: #F4F3EE; margin: 15% auto; border: 3px solid #2F3E46; border-radius: 16px; width: 90%; max-width: 500px; box-shadow: 0 8px 32px rgba(47, 62, 70, 0.3); animation: modalSlideIn 0.3s ease-out; }
@keyframes modalSlideIn { from { opacity: 0; transform: translateY(-50px) scale(0.9); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 1.2rem 1.5rem; border-bottom: 2px solid #A8A196; }
.modal-header h3 { margin: 0; color: #2F3E46; font-size: 1.2rem; }
.modal-close { background: none; border: none; font-size: 1.8rem; color: #2F3E46; cursor: pointer; transition: all 0.2s ease; }
.modal-close:hover { transform: rotate(90deg); }
.modal-body {
    padding: 1.5rem;
}

.modal-body label {
    display: block;
    margin-bottom: 8px;
    margin-top: 15px;
    font-weight: 600;
    color: #2F3E46;
}

.modal-body label:first-child {
    margin-top: 0;
}

.modal-body textarea,
.modal-body select {
    width: 100%;
    padding: 12px;
    border: 2px solid #2F3E46;
    border-radius: 8px;
    background: #F4F3EE;
    color: #2F3E46;
    font-size: 14px;
    box-sizing: border-box;
    margin-bottom: 15px;
    line-height: 1.4;
}

.modal-body textarea {
    min-height: 80px;
    resize: vertical;
}

.modal-body textarea:focus,
.modal-body select:focus {
    outline: none;
    border-color: #4FB7DB;
    background: #FFFFFF;
    box-shadow: 0 0 0 3px rgba(79, 183, 219, 0.1);
}
.modal-footer { display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; padding: 1.2rem 1.5rem; border-top: 2px solid #A8A196; }
.modal-footer-right { display: flex; gap: 0.8rem; }
.modal-btn { padding: 0.6rem 1.2rem; border: 2px solid; border-radius: 8px; font-size: 14px; cursor: pointer; }
.modal-btn-cancel { background: #F4F3EE; color: #2F3E46; border-color: #A8A196; }
.modal-btn-save { background: #2F3E46; color: #F4F3EE; border-color: #2F3E46; }
.modal-btn-delete { background: #FF6B6B; color: #FFFFFF; border-color: #FF6B6B; }
