:root {
    --sans-font: -apple-system, BlinkMacSystemFont, "Avenir Next", Avenir, "Nimbus Sans L", Roboto, "Noto Sans", "Segoe UI", Arial, Helvetica, "Helvetica Neue", sans-serif;
    --monospace-jp-font: 'Source Han Code JP', 'M+ 1M', 'MS Gothic', monospace;
    --standard-border-radius: 3px;
    --border-width: 1px;
    --border-width-wide: 2px;
    --bg: #fff;
    --text: #212121;
    /* Professional monotone/gray color scheme (aligned with splitpane.css) */
    --accent: #4a5568;
    /* Slate gray - primary */
    --accent-dim: #718096;
    /* Medium gray */
    --accent-bg: #f7fafc;
    /* Light gray background */
    --accent-dark: #2d3748;
    /* Dark gray for headers */
    --accent-link: #3182ce;
    /* Blue accent for links/actions */
    --border-dark: #868a8e;
    --border: #c6cace;
    --border-radius: 2px;
    --bold-text: #495057;
    /* Compact layout spacing */
    --gap: 0.35rem;
    --header-height: 34px;
}

*,
:before,
:after {
    box-sizing: border-box;
}

body,
header {
    padding: 0;
    margin: 0;
    font-size: 0.9em;
}

header {
    display: flex;
    gap: 0.75rem;
    justify-content: space-between;
    align-items: center;
    margin-block-start: 0;
    margin-block-end: 0;
    background: var(--accent-dark);
    grid-column: 1/-1;
    padding: 0 0.75rem;
    height: var(--header-height);
    color: white;
}

h1 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding-right: 16px;
    color: var(--accent);
    margin: 0;
    font-size: 1.15rem;
    font-family: 'Josefin Sans', "Trebuchet MS", Ubuntu, sans-serif;
    font-weight: 300;
}

h2,
h3,
h4,
h5,
h6 {
    font-family: 'Yu Gothic', sans-serif;
}

p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
}

p {
    margin: 1.5rem 0;
}

b {
    color: var(--bold-text);
    font-weight: 600;
}

a {
    text-decoration: underline;
    color: var(--accent-link);
    font-weight: 400;
}

a.disabled {
    pointer-events: none;
}

a.disabled#editButton {
    display: none;
}

button {
    border: var(--border-width) solid var(--accent);
    border-radius: var(--border-radius);
    background-color: var(--accent);
    color: white;
    padding: 0.3rem 0.4rem;
    font-size: 1.0em;
    line-height: normal;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.15s ease;
}

button:hover {
    background-color: var(--accent-dark);
    border-color: var(--accent-dark);
}

button.outlined {
    background-color: white;
    color: var(--accent);
}

button.outlined.dim {
    background-color: white;
    color: var(--accent-dim);
}

.main-content {
    overflow: auto;
    scrollbar-width: thin;
    /* Firefox: auto, thin, none */
    scrollbar-color: #dedede #f1f1f1;
    /* thumb track */
}

/* Webkit browsers */
.main-content::-webkit-scrollbar {
    width: 6px;
}

.main-content::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.main-content::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

/* Table wrapper for horizontal scrolling */
#searchResults .table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: auto;
    max-height: calc(100vh - 155px);
    position: relative;
    border-top: var(--border-width) solid var(--border);
}

/* Scroll shadow indicators using background gradients */
#searchResults .table-wrapper {
    /* Layered backgrounds: left shadow, right shadow, white base */
    background:
        /* Left shadow - fixed at scroll edge */
        linear-gradient(to right, rgba(0, 0, 0, 0.12) 0%, transparent 100%) left center,
        /* Right shadow - fixed at scroll edge */
        linear-gradient(to left, rgba(0, 0, 0, 0.12) 0%, transparent 100%) right center,
        /* White cover for left - moves with scroll */
        linear-gradient(to right, white 0%, white 100%) left center,
        /* White cover for right - moves with scroll */
        linear-gradient(to left, white 0%, white 100%) right center;
    background-repeat: no-repeat;
    background-size: 25px 100%, 25px 100%, 15px 100%, 15px 100%;
    /* Fixed shadows, scrolling covers */
    background-attachment: scroll, scroll, local, local;
}

/* Scroll indicator icon in top-right when scrollable */
#searchResults .table-wrapper.can-scroll-right::after {
    content: '→';
    position: absolute;
    right: 8px;
    top: 8px;
    background: var(--accent);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 100;
    opacity: 0.7;
    pointer-events: none;
    animation: pulse-hint 2s ease-in-out 3;
}

@keyframes pulse-hint {

    0%,
    100% {
        opacity: 0.7;
    }

    50% {
        opacity: 1;
    }
}

#searchResults table {
    width: max-content;
    min-width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
    table-layout: auto;
    border-color: transparent;
}

/* Base column widths - auto-sized but with reasonable minimums */
#searchResults thead td {
    min-width: 70px;
    max-width: 250px;
}

/* Narrower ID column */
#searchResults thead td:first-child {
    min-width: 50px;
    max-width: 70px;
}

#searchResults tr {
    height: 2em;
    transition: background-color 0.1s ease;
}

#searchResults tbody tr:hover {
    background-color: #f5f5f5;
}

/* Selected row styling */
#searchResults tbody tr.selected {
    background-color: var(--accent-bg);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

#searchResults table td {
    border-bottom: var(--border-width) solid #eee;
    border-left: var(--border-width) dotted var(--border);
    text-align: start;
    padding: 0.3rem 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

/* Apply monospace font to table cells containing Japanese data */
#searchResults td {
    font-family: var(--monospace-jp-font);
}

#searchResults td:first-child {
    border-left: none;
}

#searchResults td:last-child {
    border-right: none;
}

#searchResults thead {
    position: sticky;
    top: 0;
    z-index: 100;
    background-color: #f8f9fa;
    box-shadow: 0 1px 0 0 var(--border);
}

#searchResults thead td {
    color: #666;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 600;
    position: relative;
    background-color: #f8f9fa;
    padding: 0.35rem 0.5rem;
    border-bottom: 1px solid var(--border);
}

#searchResults thead td.collapsed {
    font-size: 0;
}

#searchResults thead td::after {
    font-size: initial;
    line-height: initial;
    color: inherit;
    display: block;
    text-align: center;
}

#searchResults thead td.collapsed::after {
    content: '\2194';
    color: var(--bold-text);
}

#searchResults tbody td.collapsed {
    width: 5px
}

#searchResults tbody td.collapsed {
    width: 1px;
    font-size: 0;
    color: transparent;
}

nav {
    display: flex;
    font-size: 0.95em;
    line-height: 1.5;
    justify-content: flex-start;
    flex-grow: 2;
    align-items: center;
    gap: 0.25rem;
}

nav a {
    color: rgba(255, 255, 255, 0.85);
    font-weight: 500;
    padding: 0.2rem 0.6rem;
    text-decoration: none;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    transition: background-color 0.15s ease;
}

nav a:hover {
    background-color: rgba(255, 255, 255, 0.15);
    color: white;
}

nav a.disabled,
nav#right-side a {
    text-decoration: none;
}

nav a.disabled {
    color: var(--accent);
    font-weight: 600;
    pointer-events: none;
    background-color: var(--bg);
}

nav#right-side {
    justify-content: flex-end;
    flex-grow: 0;
    align-items: center;
    gap: 0.5rem;
}

nav#right-side a {
    color: rgba(255, 255, 255, 0.9);
    padding: 0.2rem;
    border-radius: var(--border-radius);
}

nav#right-side a:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

#searchForm {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    margin: 0.35em auto 0.35em;
    gap: var(--gap);
}

#searchForm fieldset {
    flex-wrap: wrap;
    align-items: center;
    display: flex;
    gap: var(--gap);
    padding: 0;
    padding-inline-end: 0;
    padding-inline-start: 0.5em;
    border: none;
}

input {
    padding: 0.35em 0.5em;
    font-size: 0.95em;
    height: 1.3em;
    box-sizing: border-box;
    border-radius: var(--border-radius);
    border: var(--border-width) solid var(--border);
}

#searchForm input::placeholder {
    color: var(--border-dark);
    opacity: 1;
    font-size: 0.85em;
}

#searchForm fieldset input[type="search"] {
    width: 8.5em;
}

#searchForm fieldset input.freewordSearch {
    width: 12em;
}

#searchForm fieldset input.numericInput {
    width: 7.05em;
}

#searchForm fieldset.searchButton {
    align-items: center;
}

#searchForm #clearButton {
    background-color: var(--accent-dim);
    border-color: var(--accent-dim);
}

#searchForm legend {
    font-weight: 500;
    flex-shrink: 0;
    align-self: center;
}

#searchForm button {
    flex-shrink: 0;
    align-self: center;
}

/* First column: sticky positioning would require more complex structure */
#searchResults tr td:nth-child(1) {
    white-space: nowrap;
    min-width: 60px;
}

/* Column resize handle styling */
thead td {
    position: relative;
}

.column-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    cursor: col-resize;
    user-select: none;
    background-color: transparent;
    transition: background-color 0.2s ease;
}

.column-resize-handle:hover {
    background-color: var(--accent);
    opacity: 0.6;
}

.column-resize-handle.resizing {
    background-color: var(--accent);
    opacity: 1;
}

thead td.resizing {
    background-color: var(--accent-bg);
}

#pagination {
    display: flex;
    justify-content: right;
    margin-top: 0.75em;
    margin-right: 1em;
    gap: 8px;
}

body,
.ibm-plex-sans-jp-regular {
    font-family: "IBM Plex Sans JP", sans-serif;
    font-weight: 400;
    font-style: normal;
}

.material-symbols-outlined {
    font-size: 1.15em;
    line-height: 1.15em;
    font-variation-settings:
        'FILL' 0,
        'wght' 400,
        'GRAD' 0,
        'opsz' 24
}

.error-message {
    color: darkred;
}

.login {
    height: 100vh;
    padding: 0;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-container {
    display: flex;
    flex-direction: column;
    row-gap: 1.1em;
    align-items: flex-start;
}

.login-container h1 {
    line-height: 2.5em;
    border-bottom: var(--border-width) solid var(--border);
    width: 100%;
}

.login-container form {
    display: flex;
    flex-direction: row;
    column-gap: 0.5em;
    align-items: center;
}

.login-container form input {
    font-size: 1.0em;
    padding: 1.0em;
}

.detail-container {
    padding: 1rem;
    background-color: var(--accent-bg);
    border-top: var(--border-width) solid var(--border);
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
    font-size: 0.95em;
}

.detail-item {
    display: flex;
    flex-direction: column;
}

.detail-label {
    font-weight: 600;
    color: var(--bold-text);
    font-size: 0.85rem;
}

.detail-value {
    padding: 0.25rem 0;
    font-family: var(--monospace-jp-font);
}

.close-button {
    margin-bottom: 1rem;
}

#loading-message {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 30vh;
    font-size: 1em;
    color: #666;
}

@media (max-width: 768px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* Default state - read-only mode */
.detail-grid .edit-value {
    display: none;
}

.detail-grid .submit-container {
    display: none;
}

/* Edit mode */
.detail-grid.editing .read-only-value {
    display: none;
}

.detail-grid.editing .edit-value {
    display: block;
}

.detail-grid.editing .submit-container {
    display: flex;
    justify-content: flex-end;
    margin-top: 1rem;
}

.submit-container *:last-child {
    margin-left: 0.5rem;
}

/* Ruibetsu preview styles */
.ruibetsu-preview {
    margin-top: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.5rem;
    font-size: 0.9em;
    border-radius: var(--border-radius);
    min-height: 1.5em;
}

.ruibetsu-preview.success {
    background-color: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.ruibetsu-preview.error {
    background-color: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* Toast notification styles */
.notification {
    position: fixed;
    top: 16px;
    right: 16px;
    padding: 0.75rem 1.25rem;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 0.9em;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    max-width: 400px;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    background-color: #4caf50;
    color: white;
}

.notification-error {
    background-color: #f44336;
    color: white;
}

.notification-info {
    background-color: #2196f3;
    color: white;
}

/* Search results info */
.search-results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.15rem 0.5rem;
    margin-bottom: 0.1rem;
    font-size: 0.85em;
}

.result-count {
    color: var(--border-dark);
    font-weight: 400;
}

.result-count strong {
    color: var(--accent);
    font-weight: 700;
}

/* Utility classes for monospace Japanese text */
.monospace-jp {
    font-family: var(--monospace-jp-font);
}

.monospace-jp-alt {
    font-family: var(--monospace-jp-alt);
}

code {
    font-family: var(--monospace-jp-font);
    background-color: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 3px;
}

/* Empty state styles (no search results) */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3em 2em;
    text-align: center;
    color: #999;
    background-color: #fafafa;
    border-radius: var(--standard-border-radius);
    margin: 1.5em 0;
}

.empty-state-icon {
    font-size: 3rem !important;
    color: #bbb;
    margin-bottom: 0.75rem;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #444;
    margin: 0.5em 0;
}

.empty-state-message {
    font-size: 0.95em;
    color: #777;
    margin: 0.5em 0 1.5em;
    max-width: 500px;
}

.empty-state-suggestions {
    list-style: none;
    padding: 0;
    margin: 0;
    color: #666;
    text-align: left;
    max-width: 400px;
}

.empty-state-suggestions li {
    padding: 0.4em 0;
    position: relative;
    padding-left: 1.5em;
}

.empty-state-suggestions li::before {
    content: "•";
    position: absolute;
    left: 0.5em;
    color: var(--accent-dim);
    font-weight: bold;
}

/* Loading indicator styles */
.search-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2em 1.5em;
    color: #666;
}

.search-loading.htmx-request {
    display: flex;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid var(--accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 0.75em;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.search-loading span {
    font-size: 0.9em;
    color: var(--accent);
    font-weight: 500;
}