* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    height: 100vh;
    overflow: hidden;
    background: #f5f5f5;
}

/* 메뉴바 */
.menu-bar {
    display: flex;
    align-items: center;
    height: 32px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    padding: 0 4px;
    position: relative;
    z-index: 100;
}

.menu-item {
    position: relative;
}

.menu-button {
    background: none;
    border: none;
    padding: 4px 12px;
    font-size: 13px;
    cursor: pointer;
    color: #333;
    border-radius: 4px;
}

.menu-button:hover {
    background: #e8e8e8;
}

.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    min-width: 160px;
    z-index: 101;
}

.dropdown.open {
    display: block;
}

.dropdown-item {
    display: block;
    width: 100%;
    background: none;
    border: none;
    padding: 6px 16px;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    color: #333;
}

.dropdown-item:hover {
    background: #e8e8e8;
}

.toggle-item .check-mark {
    display: inline-block;
    width: 16px;
    visibility: hidden;
}

.toggle-item.active .check-mark {
    visibility: visible;
}

.dropdown-info {
    padding: 8px 16px;
    font-size: 13px;
    color: #555;
    line-height: 1.5;
}

/* About 팝업 */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.overlay.hidden {
    display: none;
}

.popup {
    background: #ffffff;
    border-radius: 8px;
    padding: 24px 32px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.popup h3 {
    margin-bottom: 12px;
    font-size: 18px;
    color: #333;
}

.popup p {
    font-size: 14px;
    color: #555;
    margin-bottom: 12px;
    line-height: 1.5;
}

.popup ul {
    font-size: 14px;
    color: #555;
    margin-bottom: 16px;
    padding-left: 20px;
    line-height: 1.8;
}

.popup-manual {
    max-width: 680px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.manual-content {
    overflow-y: auto;
    margin-bottom: 16px;
    padding-right: 8px;
}

.manual-content section {
    margin-bottom: 18px;
}

.manual-content h4 {
    font-size: 15px;
    color: #333;
    margin-bottom: 6px;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

.manual-content p {
    font-size: 13px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 6px;
}

.manual-content pre {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 8px 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 12px;
    line-height: 1.6;
    margin-bottom: 6px;
    overflow-x: auto;
    white-space: pre-wrap;
}

.manual-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 6px;
    font-size: 13px;
}

.manual-content td {
    padding: 3px 8px;
    border-bottom: 1px solid #eee;
    color: #555;
}

.manual-content ul {
    font-size: 13px;
    color: #555;
    padding-left: 20px;
    line-height: 1.8;
    margin-bottom: 6px;
}

.popup-close {
    display: block;
    margin-left: auto;
    padding: 6px 20px;
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
}

.popup-close:hover {
    background: #43a047;
}

.container {
    display: flex;
    height: calc(100vh - 32px);
    gap: 0;
}

.left-panel,
.right-panel {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.left-panel {
    background: #ffffff;
    border-right: 2px solid #e0e0e0;
}

.right-panel {
    background: #fafafa;
}

h2 {
    margin-bottom: 15px;
    color: #333;
    font-size: 18px;
    font-weight: 600;
}

#input {
    width: 100%;
    height: calc(100vh - 32px - 80px);
    padding: 15px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 14px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: none;
    outline: none;
    background: #fafafa;
    line-height: 1.6;
}

#input:focus {
    border-color: #4CAF50;
    background: #ffffff;
}

#output {
    background: white;
    padding: 30px 40px;
    border-radius: 8px;
    line-height: 2;
    font-family: 'Times New Roman', serif;
}

.result-item {
    margin-bottom: 20px;
    padding-left: 20px;
}

.expression {
    display: none;
}

.result {
    font-size: 20px;
    color: #1a1a1a;
    font-weight: 400;
}

.error .result {
    color: #d32f2f;
    font-size: 16px;
    font-style: italic;
}

.katex {
    font-size: 1.1em;
}

/* 설정 팝업 */
.popup-settings {
    max-width: 460px;
}

.settings-content {
    margin-bottom: 16px;
}

.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.settings-row label {
    font-size: 13px;
    color: #333;
    font-weight: 600;
    flex: 1;
}

.settings-desc {
    font-weight: 400;
    color: #888;
    font-size: 12px;
    margin-left: 6px;
}

.settings-row input[type="number"] {
    width: 90px;
    padding: 4px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    text-align: right;
}

.settings-row input[type="color"] {
    width: 40px;
    height: 28px;
    padding: 0;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

.settings-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.popup-cancel {
    background: #888 !important;
}

.popup-cancel:hover {
    background: #666 !important;
}

/* 테이블 스타일 */
.table-item {
    padding-left: 0 !important;
}

.calc-table {
    border-collapse: collapse;
    margin: 0 auto;
    font-size: 16px;
    font-family: 'Times New Roman', serif;
}

.calc-table th,
.calc-table td {
    border: 1px solid #333;
    padding: 6px 16px;
    text-align: center;
}

.calc-table th {
    background: #f0f0f0;
    font-weight: 600;
}

/* 도면 스타일 */
.dwg-item {
    padding: 10px 0 !important;
}

.dwg-svg {
    width: 100%;
    max-height: 500px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.dwg-error {
    color: #d32f2f;
    font-size: 14px;
    font-style: italic;
    margin-top: 4px;
    padding-left: 20px;
}

/* 스크롤바 스타일 */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* 메뉴바 오른쪽 정렬용 spacer */
.menu-spacer {
    flex: 1;
}

/* 문서 제목 입력 */
.doc-title {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
    text-align: center;
    border: none;
    background: transparent;
    outline: none;
    padding: 2px 8px;
    border-radius: 4px;
}

.doc-title:hover {
    background: #f0f0f0;
}

.doc-title:focus {
    background: #fff;
    border: 1px solid #ccc;
    color: #333;
}

/* 문서 상태 영역 (로그인 표시는 상위 kcsc 헤더가 담당) */
.doc-status {
    display: flex;
    align-items: center;
    padding-right: 12px;
    font-size: 13px;
}

.share-btn {
    padding: 4px 12px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
}

.share-btn:hover {
    background: #1d4ed8;
}

.hidden {
    display: none !important;
}

/* 드롭다운 구분선 */
.dropdown-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 4px 0;
}

/* 서버 저장 다이얼로그 */
.popup-save {
    max-width: 420px;
}

.save-form {
    margin-bottom: 16px;
}

.form-row {
    margin-bottom: 14px;
}

.form-row > label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.form-row input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    outline: none;
}

.form-row input[type="text"]:focus {
    border-color: #4CAF50;
}

.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
}

.radio-label input[type="radio"] {
    margin: 0;
}

.save-status {
    font-size: 13px;
    padding: 8px 0;
    min-height: 20px;
}

.save-status.success {
    color: #4CAF50;
}

.save-status.error {
    color: #d32f2f;
}

.popup-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* 서버 불러오기 다이얼로그 */
.popup-load {
    max-width: 560px;
    width: 95%;
}

.load-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 8px;
}

.load-tab {
    padding: 6px 16px;
    border: none;
    background: #f0f0f0;
    border-radius: 4px 4px 0 0;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: background 0.2s;
}

.load-tab:hover {
    background: #e0e0e0;
}

.load-tab.active {
    background: #4CAF50;
    color: #fff;
}

.load-tab.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.load-login-notice {
    padding: 12px;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    font-size: 13px;
    color: #856404;
    margin-bottom: 12px;
}

.load-login-notice a {
    color: #0d6efd;
    text-decoration: underline;
}

.load-list-container {
    min-height: 200px;
    max-height: 350px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fafafa;
}

.load-list {
    display: flex;
    flex-direction: column;
}

.load-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.15s;
}

.load-item:hover {
    background: #e8f5e9;
}

.load-item:last-child {
    border-bottom: none;
}

.load-item-info {
    flex: 1;
    min-width: 0;
}

.load-item-title {
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

.load-item-meta {
    font-size: 11px;
    color: #888;
    display: flex;
    gap: 12px;
}

.load-item-actions {
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}

.load-item:hover .load-item-actions {
    opacity: 1;
}

.load-item-btn {
    padding: 4px 10px;
    border: none;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.load-item-btn.open {
    background: #4CAF50;
    color: #fff;
}

.load-item-btn.open:hover {
    background: #43a047;
}

.load-item-btn.delete {
    background: #f44336;
    color: #fff;
}

.load-item-btn.delete:hover {
    background: #d32f2f;
}

.load-empty,
.load-loading {
    padding: 40px 20px;
    text-align: center;
    font-size: 14px;
    color: #888;
}

.load-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 12px;
    margin-bottom: 12px;
}

.page-btn {
    min-width: 32px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    background: #fff;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.15s;
}

.page-btn:hover {
    background: #f0f0f0;
    border-color: #ccc;
}

.page-btn.active {
    background: #4CAF50;
    color: #fff;
    border-color: #4CAF50;
}

.page-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 공개/비공개 배지 */
.public-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: 600;
    margin-left: 8px;
}

.public-badge.public {
    background: #e3f2fd;
    color: #1976d2;
}

.public-badge.private {
    background: #f5f5f5;
    color: #757575;
}
