:root {
    --app-font-family: "PublpageNotoSansKR", "Noto Sans KR", "Segoe UI", system-ui, sans-serif;
    --app-bg: #f5f7fa;
    --app-surface: #ffffff;
    --app-surface-muted: #f8fafc;
    --app-surface-hover: #eff4ff;
    --app-input-bg: #ffffff;
    --app-table-head-bg: #f8fafc;
    --app-text: #141824;
    --app-text-secondary: #31374a;
    --app-text-muted: #6e7891;
    --app-icon-muted: #8a94ad;
    --app-line: #e3e6ed;
    --app-primary: #3874ff;
    --app-primary-hover: #2f65df;
    --app-primary-soft: #eff4ff;
    --app-focus: rgba(56, 116, 255, 0.25);
}

.documents-shell {
    --documents-sidebar-width: 260px;
    min-height: 100vh;
    display: grid;
    grid-template-columns: var(--documents-sidebar-width) 8px minmax(0, 1fr);
    background: var(--app-bg);
    color: var(--app-text);
    font-family: var(--app-font-family);
}

.documents-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    gap: 16px;
    border-right: 1px solid var(--app-line);
    background: var(--app-surface);
    padding: 18px 14px;
    overflow: auto;
}

.documents-resize-handle {
    position: sticky;
    top: 0;
    z-index: 5;
    height: 100vh;
    border-right: 1px solid var(--app-line);
    background: linear-gradient(to right, #ffffff 0, #ffffff 3px, #e6ebf3 3px, #e6ebf3 4px, #ffffff 4px);
    cursor: col-resize;
}

.documents-resize-handle:hover,
.documents-resize-handle:focus-visible,
body.documents-resizing .documents-resize-handle {
    background: linear-gradient(to right, #ffffff 0, #ffffff 2px, #85a9ff 2px, #85a9ff 5px, #ffffff 5px);
}

body.documents-resizing {
    cursor: col-resize;
    user-select: none;
}

.documents-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--app-text);
    font-size: 17px;
    font-weight: 900;
    text-decoration: none;
}

.documents-brand:hover {
    color: var(--app-text);
}

.documents-brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: var(--app-primary);
    color: #fff;
    font-weight: 900;
}

.documents-brand-mark {
    width: 32px;
    height: 32px;
}

.documents-brand-logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex: 0 0 auto;
}

.documents-upload-body label {
    display: grid;
    gap: 6px;
    color: var(--app-text-muted);
    font-size: 11px;
    font-weight: 800;
}

.documents-tree {
    border: 1px solid var(--app-line);
    border-radius: 6px;
    background: #ffffff;
    box-shadow: inset 0 0 0 1px rgba(227, 230, 237, 0.35);
    overflow: hidden;
}

.documents-tree-root {
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 12px;
    border-bottom: 1px solid #e8ebf1;
    background: #eef0f2;
    color: #111827;
    font-size: 12px;
    font-weight: 900;
}

.documents-tree-root-action {
    width: 24px;
    height: 22px;
    border: 1px solid #d0d7e2;
    border-radius: 4px;
    background: #ffffff;
    color: #2563eb;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 900;
    line-height: 1;
}

.documents-tree-root-action:hover {
    border-color: #9eb8ff;
    background: #eff4ff;
}

.documents-tree-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 8px 8px 12px 20px;
    list-style: none;
}

.documents-tree-list.children {
    gap: 0;
    margin: -1px 0 2px 13px;
    padding: 0 0 0 13px;
}

.documents-tree-branch {
    min-width: 0;
    list-style: none;
}

.documents-tree-item {
    position: relative;
    min-width: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: 23px;
    padding-left: 10px;
}

.documents-tree-item-create {
    margin: 2px 0;
}

.documents-tree-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: -1px;
    bottom: -1px;
    border-left: 1px dotted #b9c0cc;
}

.documents-tree-item::after {
    content: "";
    position: absolute;
    left: 0;
    top: 12px;
    width: 10px;
    border-top: 1px dotted #b9c0cc;
}

.documents-tree-document {
    position: relative;
    min-width: 0;
    display: grid;
    min-height: 22px;
    padding-left: 10px;
    list-style: none;
}

.documents-tree-document::before {
    content: "";
    position: absolute;
    left: 0;
    top: -1px;
    bottom: -1px;
    border-left: 1px dotted #b9c0cc;
}

.documents-tree-document::after {
    content: "";
    position: absolute;
    left: 0;
    top: 11px;
    width: 10px;
    border-top: 1px dotted #b9c0cc;
}

.documents-tree-link {
    min-width: 0;
    min-height: 23px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #252a36;
    display: grid;
    grid-template-columns: 12px minmax(0, auto) auto;
    align-items: center;
    justify-content: start;
    gap: 5px;
    padding: 2px 5px;
    font: 800 12px/1.2 var(--app-font-family);
    text-align: left;
}

.documents-tree-document-link {
    min-width: 0;
    min-height: 22px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: #3a4151;
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr);
    align-items: center;
    justify-content: start;
    gap: 5px;
    padding: 2px 5px;
    font: 800 11px/1.2 var(--app-font-family);
    text-align: left;
}

.documents-tree-link:hover,
.documents-tree-item.active .documents-tree-link,
.documents-tree-document-link:hover,
.documents-tree-document.active .documents-tree-document-link {
    background: #f3f6fb;
    color: #111827;
}

.tree-file-icon {
    position: relative;
    width: 9px;
    height: 11px;
    border: 1px solid #aeb7c7;
    border-radius: 1px;
    background: #ffffff;
}

.tree-file-icon::before,
.tree-file-icon::after {
    content: "";
    position: absolute;
    left: 2px;
    right: 2px;
    height: 1px;
    background: #aeb7c7;
}

.tree-file-icon::before {
    top: 3px;
}

.tree-file-icon::after {
    top: 6px;
}

.tree-bootstrap-icon {
    width: 12px;
    color: #8a94ad;
    font-size: 11px;
    line-height: 1;
    text-align: center;
}

.documents-tree-item.active .tree-bootstrap-icon,
.documents-tree-document.active .tree-bootstrap-icon {
    color: #3b6eea;
}

.tree-document-icon {
    position: relative;
    width: 9px;
    height: 11px;
    border: 1px solid #b8c1d1;
    border-radius: 1px;
    background: #ffffff;
}

.tree-document-icon::before {
    content: "";
    position: absolute;
    right: -1px;
    top: -1px;
    width: 4px;
    height: 4px;
    border-left: 1px solid #b8c1d1;
    border-bottom: 1px solid #b8c1d1;
    background: #eef4ff;
}

.tree-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-count {
    color: #ff5a1f;
    font-size: 10px;
    font-weight: 900;
}

.documents-tree-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    opacity: 0;
    pointer-events: none;
}

.documents-tree-item:hover .documents-tree-actions,
.documents-tree-item:focus-within .documents-tree-actions {
    opacity: 1;
    pointer-events: auto;
}

.tree-action {
    min-height: 21px;
    border: 1px solid #d7dde8;
    border-radius: 4px;
    background: #fff;
    color: #64748b;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.tree-action:hover {
    border-color: #9eb8ff;
    background: #eff4ff;
    color: #1d4ed8;
}

.tree-action.danger:hover {
    border-color: #fecaca;
    background: #fff1f2;
    color: #b91c1c;
}

.tree-action.confirm {
    color: #1d4ed8;
}

.documents-tree-edit {
    grid-column: 1 / 3;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 4px;
    align-items: center;
    padding: 2px 0;
}

.documents-folder-rename {
    height: 26px;
    min-width: 0;
    font-size: 11px;
}

.documents-main {
    min-width: 0;
    padding: 28px;
}

.top-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.documents-header-actions {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.documents-language-toggle {
    min-height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    background: #fff;
    color: var(--app-text-muted);
    padding: 0 10px;
    font: 900 12px/1 var(--app-font-family);
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.documents-language-toggle:hover {
    border-color: #9eb8ff;
    background: #eff4ff;
}

.documents-language-toggle .active {
    color: #1d4ed8;
}

.documents-language-toggle .divider {
    color: #cbd5e1;
}

.top-header h1 {
    margin: 0;
    font-size: 28px;
    font-weight: 900;
}

.top-header p {
    margin: 8px 0 0;
    color: var(--app-text-muted);
    font-size: 14px;
}

.documents-account {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    background: #fff;
    padding: 8px;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.04);
}

.documents-account-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    background: #eef6ff;
    color: var(--app-primary);
    font-size: 14px;
    font-weight: 900;
    flex: 0 0 auto;
}

.documents-account-text {
    display: grid;
    min-width: 0;
    gap: 2px;
}

.documents-account-text strong,
.documents-account-text span {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.documents-account-text strong {
    color: var(--app-text);
    font-size: 13px;
    font-weight: 900;
}

.documents-account-text span {
    color: var(--app-text-muted);
    font-size: 11px;
    font-weight: 700;
}

.documents-account-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    color: var(--app-text-muted);
    text-decoration: none;
    flex: 0 0 auto;
}

.documents-account-logout:hover {
    border-color: #fecaca;
    background: #fff1f2;
    color: #dc2626;
}

.panel {
    background: var(--app-surface);
    border: 1px solid var(--app-line);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
    overflow: hidden;
}

.panel + .panel {
    margin-top: 16px;
}

.panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--app-line);
    padding: 14px 16px;
}

.panel-header h2 {
    margin: 0;
    color: var(--app-text);
    font-size: 17px;
    font-weight: 900;
}

.panel-header p {
    margin: 5px 0 0;
    color: var(--app-text-muted);
    font-size: 12px;
}

.documents-upload-body {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr) 150px auto;
    gap: 12px;
    align-items: end;
    padding: 16px;
}

input,
select,
textarea {
    border: 1px solid var(--app-line);
    border-radius: 6px;
    background: var(--app-input-bg);
    color: var(--app-text);
    padding: 0 10px;
    font: 800 12px/1.2 var(--app-font-family);
}

input,
select {
    height: 34px;
}

input[type="file"] {
    height: auto;
    min-height: 34px;
    padding: 7px 10px;
}

.documents-toggle {
    min-height: 34px;
    grid-auto-flow: column;
    align-items: center;
    justify-content: start;
    color: var(--app-text);
}

.documents-toggle input {
    width: 16px;
    height: 16px;
}

.btn {
    border: 0;
    border-radius: 6px;
    min-height: 36px;
    padding: 0 12px;
    font-weight: 800;
    cursor: pointer;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1;
    white-space: nowrap;
    text-decoration: none;
}

.btn .bi {
    font-size: 14px;
    line-height: 1;
}

.btn.primary {
    background: var(--app-primary);
    color: #fff;
}

.btn.primary:hover {
    background: var(--app-primary-hover);
}

.btn.tiny {
    min-height: 34px;
    padding: 0 10px;
    background: var(--app-surface-muted);
    border: 1px solid var(--app-line);
    color: var(--app-text);
}

.btn.tiny.active {
    border-color: #85a9ff;
    background: var(--app-primary-soft);
    color: #1d4ed8;
}

.btn.danger {
    border: 1px solid rgba(220, 38, 38, 0.28);
    background: #fff1f2;
    color: #b91c1c;
}

.btn.icon-only {
    width: 34px;
    min-width: 34px;
    padding: 0;
    font-size: 11px;
}

.btn:disabled {
    border-color: #cbd5e1;
    background: #f1f5f9;
    color: #94a3b8;
    cursor: no-drop;
    opacity: 1;
}

.documents-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
    padding: 16px;
}

.document-card {
    min-width: 0;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    background: var(--app-surface);
    padding: 16px;
}

.document-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.document-card h3 {
    margin: 0;
    color: var(--app-text);
    font-size: 16px;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.document-card p {
    margin: 6px 0 0;
    color: var(--app-text-muted);
    font-size: 12px;
    font-weight: 800;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 22px;
    border-radius: 999px;
    padding: 0 8px;
    font-size: 10px;
    font-weight: 900;
    white-space: nowrap;
}

.status-badge.published {
    background: #f0fdf4;
    color: #15803d;
}

.status-badge.private {
    background: #f8fafc;
    color: #64748b;
}

.document-meta {
    display: grid;
    gap: 8px;
    margin: 14px 0;
}

.document-meta div {
    min-width: 0;
}

.document-meta dt {
    color: var(--app-text-muted);
    font-size: 11px;
    font-weight: 900;
}

.document-meta dd {
    margin: 3px 0 0;
    color: var(--app-text-secondary);
    font-size: 12px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.document-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.document-actions.compact {
    gap: 6px;
}

.document-actions.compact .btn.tiny {
    min-height: 28px;
    padding: 0 8px;
    font-size: 11px;
}

.document-file-button {
    position: relative;
    overflow: hidden;
}

.document-file-button input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.documents-preview-panel {
    min-height: 560px;
}

.documents-folder-list {
    min-width: 0;
}

.documents-list-table-wrap {
    overflow-x: auto;
}

.documents-list-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.documents-list-table th,
.documents-list-table td {
    border-bottom: 1px solid var(--app-line);
    padding: 10px 12px;
    color: var(--app-text-secondary);
    font-size: 12px;
    font-weight: 800;
    text-align: left;
    vertical-align: middle;
}

.documents-list-table th {
    background: var(--app-table-head-bg);
    color: var(--app-text-muted);
    font-size: 11px;
    font-weight: 900;
}

.documents-list-table th:nth-child(1) {
    width: 34%;
}

.documents-list-table th:nth-child(2) {
    width: 78px;
}

.documents-list-table th:nth-child(3) {
    width: 92px;
}

.documents-list-table th:nth-child(4) {
    width: 142px;
}

.documents-list-table th:nth-child(5) {
    width: 74px;
}

.documents-list-table th:nth-child(6) {
    width: 330px;
}

.documents-list-table tr:hover td {
    background: #fbfdff;
}

.documents-list-title {
    min-width: 0;
    max-width: 100%;
    border: 0;
    background: transparent;
    color: var(--app-text);
    display: inline-grid;
    grid-template-columns: 16px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
    padding: 0;
    font: 900 12px/1.25 var(--app-font-family);
    text-align: left;
}

.documents-list-title:hover {
    color: #1d4ed8;
}

.documents-list-title span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.documents-preview {
    min-width: 0;
}

.documents-preview-summary {
    display: grid;
    gap: 10px;
    border-bottom: 1px solid var(--app-line);
    padding: 16px 18px;
}

.documents-preview-title-row {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.documents-preview-title-row h2 {
    margin: 0;
    color: var(--app-text);
    font-size: 20px;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.documents-preview-title-row p {
    margin: 5px 0 0;
    color: var(--app-text-muted);
    font-size: 12px;
    font-weight: 900;
}

.documents-preview-action-row {
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.documents-preview-url {
    min-width: 0;
    color: var(--app-text-secondary);
    font-size: 12px;
    font-weight: 800;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.documents-preview-body {
    margin: 0 auto;
    padding: 26px;
    color: #1f2937;
    font-size: 15px;
    line-height: 1.72;
}

.documents-preview-body.width-70 {
    width: min(70vw, 1120px);
}

.documents-preview-body.width-100 {
    width: 100%;
}

.documents-preview-frame-wrap {
    margin: 0 auto;
    padding: 18px;
}

.documents-preview-frame-wrap.width-70 {
    width: min(70vw, 1120px);
}

.documents-preview-frame-wrap.width-100 {
    width: 100%;
}

.documents-preview-frame {
    width: 100%;
    min-height: 720px;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    background: #fff;
}

.documents-preview-body h1,
.documents-preview-body h2,
.documents-preview-body h3,
.documents-preview-body h4 {
    color: #111827;
    line-height: 1.25;
    font-weight: 900;
}

.documents-preview-body h1 {
    font-size: 27px;
}

.documents-preview-body h2 {
    margin-top: 30px;
    font-size: 22px;
}

.documents-preview-body h3 {
    margin-top: 24px;
    font-size: 18px;
}

.documents-preview-body p {
    margin: 0 0 15px;
}

.documents-preview-body img {
    max-width: 100%;
    height: auto;
}

.documents-preview-body table {
    display: block;
    width: 100%;
    overflow-x: auto;
    border-collapse: collapse;
}

.documents-preview-body th,
.documents-preview-body td {
    border: 1px solid var(--app-line);
    padding: 8px 10px;
}

.documents-preview-body th {
    background: #f8fafc;
    color: var(--app-text-secondary);
    font-weight: 900;
}

.documents-preview-body pre {
    overflow-x: auto;
    border: 1px solid var(--app-line);
    border-radius: 8px;
    background: #0f172a;
    color: #e5e7eb;
    padding: 14px;
}

.documents-preview-body code {
    border-radius: 5px;
    background: #f1f5f9;
    color: #0f172a;
    padding: 2px 5px;
    font-size: 0.92em;
}

.documents-preview-body pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

.form-message {
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 800;
}

.form-message.error {
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.form-message.success {
    border: 1px solid #bbf7d0;
    background: #f0fdf4;
    color: #15803d;
}

.empty-state {
    display: grid;
    gap: 6px;
    justify-items: center;
    padding: 34px 16px;
    color: var(--app-text-muted);
    text-align: center;
}

.empty-state strong {
    color: var(--app-text);
    font-size: 13px;
    font-weight: 900;
}

.empty-state span {
    font-size: 12px;
    line-height: 1.45;
}

.documents-modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: grid;
    place-items: center;
    background: rgba(15, 23, 42, 0.42);
    padding: 18px;
}

.documents-confirm-modal {
    width: min(420px, 100%);
    border: 1px solid var(--app-line);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 23, 42, 0.24);
    padding: 18px;
}

.documents-confirm-header {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.documents-confirm-icon {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: #fff1f2;
    color: #dc2626;
    font-size: 18px;
    flex: 0 0 auto;
}

.documents-confirm-header h2 {
    margin: 0;
    color: var(--app-text);
    font-size: 18px;
    font-weight: 900;
}

.documents-confirm-header p {
    margin: 5px 0 0;
    color: var(--app-text-muted);
    font-size: 12px;
    font-weight: 800;
    overflow-wrap: anywhere;
}

.documents-confirm-message {
    margin: 16px 0 0;
    color: var(--app-text-secondary);
    font-size: 13px;
    line-height: 1.55;
    font-weight: 800;
}

.documents-confirm-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

@media (max-width: 900px) {
    .documents-shell {
        grid-template-columns: 1fr;
    }

    .documents-resize-handle {
        display: none;
    }

    .documents-sidebar {
        position: static;
        height: auto;
    }

    .documents-tree {
        max-height: 260px;
        overflow: auto;
    }

    .documents-main {
        padding: 20px;
    }

    .top-header {
        flex-wrap: wrap;
    }

    .documents-upload-body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .documents-main {
        padding: 16px;
    }

    .top-header h1 {
        font-size: 24px;
    }

    .documents-account {
        width: 100%;
    }

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

    .documents-account-text {
        flex: 1 1 auto;
    }

    .documents-account-text strong,
    .documents-account-text span {
        max-width: none;
    }

    .documents-card-grid {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .document-actions .btn {
        flex: 1 1 128px;
    }
}
