:root {
    --bg: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #d1d5db;
    --brand: #0f766e;
    --brand-bg: #ecfeff;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
    line-height: 1.5;
}

.container {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
}

.site-header {
    border-bottom: 1px solid var(--line);
    background: #fff;
}

.header-inner {
    padding: 1rem 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.site-title {
    color: var(--brand);
    text-decoration: none;
    font-weight: 700;
    font-size: 1.25rem;
}

.site-title:hover {
    text-decoration: underline;
}

.header-admin-link {
    color: #0369a1;
    text-decoration: none;
    font-size: 0.95rem;
}

.header-admin-link:hover {
    text-decoration: underline;
}

.section {
    margin: 1.5rem 0 2rem;
}

h1 {
    margin: 0 0 0.5rem;
    font-size: 1.6rem;
}

h2 {
    margin: 0 0 0.75rem;
    font-size: 1.2rem;
}

.category-block {
    margin-top: 1.5rem;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.list-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.list-table th,
.list-table td {
    padding: 0.7rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
    white-space: nowrap;
}

.list-table th {
    background: #f8fafc;
    font-weight: 600;
}

.list-table tr:last-child td {
    border-bottom: none;
}

.list-table a {
    color: #0b4f6c;
}

.muted {
    color: var(--muted);
    font-size: 0.95rem;
}

.alert {
    margin-top: 0.8rem;
    padding: 0.7rem 0.9rem;
    border-radius: 8px;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border: 1px solid #fecaca;
}

.empty-state {
    margin-top: 1rem;
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.breadcrumb {
    display: flex;
    gap: 0.4rem;
    align-items: center;
    color: var(--muted);
    margin-bottom: 0.8rem;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: #0b4f6c;
}

.meta-line {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    color: var(--muted);
    margin-bottom: 1rem;
}

.description-box {
    margin-bottom: 1rem;
    padding: 0.8rem 1rem;
    border: 1px solid #bae6fd;
    background: #f0f9ff;
    border-radius: 8px;
}

.description-body {
    white-space: normal;
}

.viewer-box {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.8rem;
    background: #fff;
}

.controls-grid {
    display: grid;
    gap: 0.75rem;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 0.8rem;
}

.control {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.control input,
.control select,
.control button,
.control a {
    height: 2.25rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.45rem 0.65rem;
    font-size: 0.95rem;
    background: #fff;
    color: var(--text);
}

.button-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.control button,
.control a {
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.control button:hover,
.control a:hover {
    background: #f3f4f6;
}

.column-toggle {
    margin-bottom: 0.8rem;
    padding: 0.4rem 0.5rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fafafa;
}

.column-toggle-list {
    margin-top: 0.6rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem 1rem;
}

.column-toggle-list label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.92rem;
}

#table-status {
    margin-bottom: 0.55rem;
}

#csv-table {
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.site-footer {
    border-top: 1px solid var(--line);
    margin-top: 2rem;
    background: #fff;
}

.footer-inner {
    padding: 1rem 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.admin-app {
    margin-top: 1rem;
}

.admin-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: 280px minmax(0, 1fr);
}

.admin-actions {
    margin-top: 1rem;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.admin-panel {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.9rem;
    background: #fff;
}

.admin-panel h2 {
    margin-bottom: 0.8rem;
}

.admin-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.admin-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 200px;
}

.admin-field-inline {
    align-items: center;
    margin-bottom: 0.2rem;
}

.admin-field input,
.admin-field select {
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 2.15rem;
    padding: 0.4rem 0.55rem;
    font-size: 0.95rem;
}

.admin-ghost-btn {
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 2.15rem;
    padding: 0.4rem 0.75rem;
    background: #fff;
    cursor: pointer;
}

.admin-ghost-btn:hover {
    background: #f1f5f9;
}

.admin-count {
    margin-left: auto;
}

.admin-category-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.admin-category-list button {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 0.45rem 0.55rem;
    text-align: left;
    cursor: pointer;
}

.admin-category-list button.active {
    border-color: #0284c7;
    background: #eff6ff;
}

.admin-selection {
    margin-bottom: 0.6rem;
    padding: 0.45rem 0.6rem;
    border: 1px dashed #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
}

.admin-form {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.admin-form label {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.92rem;
}

.admin-form input[type="text"],
.admin-form input[type="file"],
.admin-form button {
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 2.2rem;
    padding: 0.4rem 0.6rem;
    font-size: 0.95rem;
}

.admin-form button {
    cursor: pointer;
    background: #f8fafc;
}

.admin-form button:hover {
    background: #e2e8f0;
}

.admin-form button.danger {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.admin-form button.danger:hover {
    background: #fee2e2;
}

.checkbox-row {
    flex-direction: row;
    align-items: center;
    gap: 0.4rem;
}

.admin-dropzone {
    border: 1px dashed #94a3b8;
    border-radius: 10px;
    padding: 0.8rem;
    text-align: center;
    color: #334155;
    background: #f8fafc;
}

.admin-dropzone.dragover {
    border-color: #0284c7;
    background: #eff6ff;
}

.admin-row-selected {
    background: #eef6ff;
}

.admin-inline-actions {
    display: flex;
    gap: 0.35rem;
}

.admin-inline-actions button,
.admin-inline-actions a {
    display: inline-flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    min-height: 1.8rem;
    padding: 0.2rem 0.45rem;
    background: #fff;
    font-size: 0.83rem;
    text-decoration: none;
    color: #1f2937;
    cursor: pointer;
}

.admin-inline-actions button:hover,
.admin-inline-actions a:hover {
    background: #f1f5f9;
}

#admin-status {
    margin-top: 1rem;
}

.admin-xplorer {
    margin-top: 1rem;
}

.xplorer-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
    align-items: end;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.75rem;
    background: #ffffff;
}

.xplorer-toolbar button {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    min-height: 2.1rem;
    padding: 0.35rem 0.65rem;
    background: #f8fafc;
    cursor: pointer;
}

.xplorer-toolbar button:hover {
    background: #e2e8f0;
}

.xplorer-toolbar button.danger {
    border-color: #fecaca;
    color: #b91c1c;
    background: #fef2f2;
}

.xplorer-inline-field {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 180px;
}

.xplorer-inline-field input,
.xplorer-inline-field select {
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    min-height: 2.1rem;
    padding: 0.35rem 0.55rem;
}

.xplorer-count {
    margin-left: auto;
}

.xplorer-layout {
    margin-top: 0.85rem;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr) 280px;
    gap: 0.8rem;
}

.xplorer-sidebar,
.xplorer-main,
.xplorer-inspector {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 0.8rem;
}

.xplorer-sidebar h2,
.xplorer-inspector h2 {
    margin: 0 0 0.65rem;
    font-size: 1rem;
}

.xplorer-tree {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.xplorer-tree button {
    width: 100%;
    text-align: left;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 0.38rem 0.5rem;
    background: #fff;
    cursor: pointer;
}

.xplorer-tree button.active {
    border-color: #0ea5e9;
    background: #eff6ff;
}

.xplorer-tree button.dragover {
    border-color: #0f766e;
    background: #ecfeff;
}

.xplorer-breadcrumb {
    font-size: 0.92rem;
    color: #475569;
    margin-bottom: 0.55rem;
}

.xplorer-dropzone {
    border: 1px dashed #94a3b8;
    border-radius: 10px;
    padding: 0.65rem;
    text-align: center;
    color: #334155;
    background: #f8fafc;
    margin-bottom: 0.6rem;
}

.xplorer-dropzone.dragover {
    border-color: #0284c7;
    background: #eff6ff;
}

.xplorer-file-area {
    min-height: 420px;
    max-height: 65vh;
    overflow: auto;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 0.65rem;
}

.xplorer-file-area.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.6rem;
}

.xplorer-file-area.list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.xplorer-item {
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #fff;
    padding: 0.55rem;
    cursor: pointer;
    user-select: none;
}

.xplorer-item:hover {
    border-color: #0ea5e9;
    background: #f8fbff;
}

.xplorer-item.selected {
    border-color: #0284c7;
    background: #eaf4ff;
}

.xplorer-item-title {
    font-weight: 600;
    color: #0f172a;
    margin-bottom: 0.3rem;
    word-break: break-all;
}

.xplorer-item-meta {
    color: #64748b;
    font-size: 0.84rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.xplorer-item-actions {
    margin-top: 0.45rem;
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

.xplorer-item-actions button,
.xplorer-item-actions a {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 0.2rem 0.42rem;
    background: #fff;
    font-size: 0.8rem;
    text-decoration: none;
    color: #1f2937;
    cursor: pointer;
}

.xplorer-item-actions button:hover,
.xplorer-item-actions a:hover {
    background: #f1f5f9;
}

.xplorer-item-list-row {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.75rem;
    align-items: center;
}

.xplorer-selection-detail {
    margin-top: 0.65rem;
    font-size: 0.9rem;
    color: #334155;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.xplorer-dialog {
    border: none;
    border-radius: 12px;
    padding: 0;
    width: min(520px, calc(100% - 1.5rem));
}

.xplorer-dialog::backdrop {
    background: rgba(15, 23, 42, 0.38);
}

.xplorer-dialog .admin-form {
    padding: 1rem;
}

.xplorer-dialog .admin-form h3 {
    margin: 0 0 0.55rem;
}

.xplorer-dialog-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.classic-explorer {
    border: 1px solid #a1a1a1;
    background: linear-gradient(180deg, #f8f8f8 0%, #efefef 100%);
    box-shadow: inset 0 1px 0 #fff;
}

.classic-toolbar {
    border: none;
    border-bottom: 1px solid #b7b7b7;
    border-radius: 0;
    background: linear-gradient(180deg, #fcfcfc 0%, #e8e8e8 100%);
    padding: 0.45rem 0.55rem;
    gap: 0.4rem;
}

.classic-toolbar button {
    border-color: #b9b9b9;
    border-radius: 3px;
    min-height: 1.95rem;
    background: linear-gradient(180deg, #ffffff 0%, #ececec 100%);
    font-size: 0.86rem;
}

.xplorer-address {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    border-bottom: 1px solid #c6c6c6;
    background: #f4f4f4;
    padding: 0.35rem 0.55rem;
    font-size: 0.88rem;
}

.xplorer-address-label {
    color: #4b5563;
}

.classic-layout {
    margin-top: 0;
    gap: 0;
    border-top: 1px solid #fff;
    grid-template-columns: 300px minmax(0, 1fr);
    min-height: 520px;
}

.classic-sidebar {
    border: none;
    border-right: 1px solid #b9b9b9;
    border-radius: 0;
    background: #fafafa;
    padding: 0.35rem 0.4rem;
    overflow: auto;
}

.classic-main {
    border: none;
    border-radius: 0;
    background: #fff;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.xplorer-tree {
    list-style: none;
    margin: 0;
    padding: 0;
}

.xplorer-tree-item {
    list-style: none;
}

.xplorer-tree-children {
    margin: 0;
    padding: 0 0 0 1.15rem;
    border-left: 1px dotted #c5c5c5;
}

.xplorer-tree-row {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    margin: 0.05rem 0;
    border-radius: 2px;
}

.xplorer-tree-row.dragover {
    background: #e0f2fe;
}

.xplorer-tree-expander {
    width: 1.1rem;
    height: 1.1rem;
    border: none;
    background: transparent;
    color: #555;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0;
}

.xplorer-tree-expander:disabled {
    cursor: default;
    color: transparent;
}

.xplorer-tree-node {
    flex: 1;
    text-align: left;
    border: none;
    background: transparent;
    padding: 0.18rem 0.25rem;
    border-radius: 2px;
    cursor: pointer;
    color: #111827;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.xplorer-tree-node .icon {
    font-size: 0.9rem;
}

.xplorer-tree-node:hover {
    background: #f1f5f9;
}

.xplorer-tree-node.active {
    background: #c7e2ff;
}

.xplorer-dropzone {
    margin: 0.45rem;
    border: 1px dashed #9ca3af;
    border-radius: 4px;
    padding: 0.45rem;
    text-align: center;
    background: #f9fafb;
    font-size: 0.84rem;
}

.xplorer-dropzone.dragover {
    background: #e0f2fe;
    border-color: #0284c7;
}

.xplorer-file-area {
    margin: 0 0.45rem 0.45rem;
    border: 1px solid #c7c7c7;
    border-radius: 0;
    min-height: 420px;
    max-height: 62vh;
    overflow: auto;
    background: #fff;
    padding: 0.5rem;
}

.xplorer-file-area.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 0.5rem;
}

.xplorer-file-area.list {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.xplorer-item {
    border: 1px solid #d4d4d4;
    border-radius: 3px;
    background: #fff;
    padding: 0.42rem 0.45rem;
    cursor: pointer;
    user-select: none;
}

.xplorer-item.folder {
    background: linear-gradient(180deg, #fffdf3 0%, #fff8dd 100%);
}

.xplorer-item:hover {
    border-color: #60a5fa;
    background: #f6fbff;
}

.xplorer-item.selected {
    border-color: #1d4ed8;
    background: #dbeafe;
}

.xplorer-item.dragover {
    border-color: #0ea5e9;
    background: #e0f2fe;
}

.xplorer-item-head {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
}

.xplorer-item-head .icon {
    font-size: 1rem;
}

.xplorer-item-head .title {
    font-weight: 600;
    word-break: break-all;
}

.xplorer-item-sub,
.xplorer-item-meta {
    margin-top: 0.25rem;
    color: #475569;
    font-size: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.xplorer-item-actions {
    margin-top: 0.3rem;
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.xplorer-item-actions a {
    border: 1px solid #c7c7c7;
    border-radius: 3px;
    padding: 0.12rem 0.35rem;
    font-size: 0.76rem;
    text-decoration: none;
    color: #1f2937;
    background: #fff;
}

.xplorer-item-actions a:hover {
    background: #f1f5f9;
}

.xplorer-statusbar {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 0.35rem;
    align-items: center;
    border-top: 1px solid #b7b7b7;
    background: #f4f4f4;
    padding: 0.35rem 0.55rem;
    font-size: 0.85rem;
}

.xplorer-selection-detail {
    color: #334155;
    font-size: 0.84rem;
}

@media (max-width: 640px) {
    .container {
        width: min(1120px, calc(100% - 1rem));
    }

    .list-table th,
    .list-table td {
        padding: 0.6rem;
    }
}

@media (max-width: 960px) {
    .admin-grid,
    .admin-actions {
        grid-template-columns: 1fr;
    }

    .admin-count {
        margin-left: 0;
        width: 100%;
    }

    .xplorer-layout {
        grid-template-columns: 1fr;
    }

    .xplorer-count {
        margin-left: 0;
        width: 100%;
    }
}
