* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f8f8;
    background-image:
        linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px),
        linear-gradient(rgba(0,0,0,0.01) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.01) 1px, transparent 1px);
    background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
    background-position: -1px -1px, -1px -1px, -1px -1px, -1px -1px;
    color: #333;
    line-height: 1.6;
}

/* ヘッダー */
.header {
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    background: rgba(248, 248, 248, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid #e5e5e5;
    padding: 20px 60px;
}

.nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
    min-width: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
}

.logo-image {
    height: 32px;
    width: auto;
}

.nav-link {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    text-decoration: none;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}

.nav-link:hover {
    opacity: 0.6;
}

.nav-icon {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #333;
    text-decoration: none;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
    margin-left: 16px;
}

.nav-icon:hover {
    opacity: 0.6;
}

.nav-icon-label {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.nav-icon-active {
    opacity: 0.5;
}

.search-container {
    position: relative;
    flex: 0 1 300px;
    min-width: 160px;
}

.search-input {
    width: 100%;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: white;
    font-size: 16px;
    color: #333;
    transition: border-color 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: #007AFF;
}

.search-input::placeholder {
    color: #767676;
}

/* サイドバー */
.sidebar {
    width: 280px;
    background: white;
    border-right: 1px solid #e5e5e5;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 999;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 100px 25px 25px;
    border-bottom: 1px solid #f0f0f0;
    position: relative;
}

.sidebar-close-btn {
    position: absolute;
    top: 110px;
    right: 25px;
    background: none;
    border: none;
    cursor: pointer;
    color: #999;
    font-size: 24px;
    line-height: 1;
    transition: all 0.2s ease;
    padding: 0;
    width: 24px;
    height: 24px;
    display: none; /* デフォルトは非表示 */
    align-items: center;
    justify-content: center;
}

.sidebar-close-btn:hover {
    color: #333;
    transform: scale(1.1);
}

/* スマホのみ×ボタンを表示 */
@media (max-width: 768px) {
    .sidebar-close-btn {
        display: flex;
    }
}

.sidebar-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.sidebar-subtitle {
    color: #666;
    font-size: 12px;
}

.sidebar-section {
    padding: 25px;
    border-bottom: 1px solid #f0f0f0;
}

.sidebar-section h3 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.category-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.category-count {
    font-size: 12px;
    color: #666;
    font-weight: 400;
}

.category-reset-btn {
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.category-reset-btn:hover {
    color: #FF6B6B;
    transform: rotate(90deg);
}

.category-reset-btn.hidden {
    display: none;
}

.filter-group {
    margin-bottom: 20px;
}

.filter-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #666;
}

.filter-select {
    width: 100%;
    padding: 8px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #333;
    font-size: 13px;
}

.filter-select:focus {
    outline: none;
    border-color: #007AFF;
}

.category-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-btn {
    padding: 6px 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.category-btn:hover {
    background: #f8f8f8;
}

.category-btn.active {
    background: #333;
    color: white;
    border-color: #333;
}

.stats {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 12px;
}

.stat-label {
    color: #666;
}

.stat-value {
    color: #333;
    font-weight: 500;
}

/* メインコンテンツ */
.main-content {
    margin-left: 0;
    transition: margin-left 0.3s ease;
}

.main-content.sidebar-open {
    margin-left: 280px;
}

.content-header {
    position: sticky;
    top: 80px;
    padding: 20px 60px;
    z-index: 100;
}

.controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.sidebar-toggle {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 8px 12px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar-toggle:hover {
    background: #f8f8f8;
}

.sidebar-toggle svg {
    width: 16px;
    height: 16px;
}

.view-modes {
    display: flex;
    gap: 1px;
    border: 1px solid #ddd;
    border-radius: 6px;
    overflow: hidden;
}

.view-btn {
    padding: 8px 12px;
    background: white;
    border: none;
    color: #666;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.view-btn:hover {
    background: #f8f8f8;
}

.view-btn.active {
    background: #333;
    color: white;
}

/* フォントギャラリー */
.font-section {
    padding: 60px;
    max-width: 1400px;
    margin: 0 auto;
}

.font-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

.font-grid.grid-view {
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 60px;
}

.font-card {
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.font-card:not(:last-child) {
    border-bottom: 1px solid #e5e5e5;
}

.font-card:hover {
    background: #fafafa;
}

.font-card.grid-view {
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    padding: 40px;
}

.font-card.grid-view:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

/* フォントプレビュー部分 */
.font-preview-section {
    padding: 30px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    width: 100%;
}

.font-card.grid-view .font-preview-section {
    padding: 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 30px;
}

.font-info {
    flex: 0 0 220px;
    padding-right: 20px;
}

.font-card.grid-view .font-info {
    flex: none;
    width: 100%;
    padding-right: 0;
}

.font-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
    letter-spacing: 0.3px;
}

.font-name-text {
    flex: 1;
}

.font-meta {
    font-size: 12px;
    color: #666;
    margin-bottom: 8px;
}

.font-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.font-tag {
    display: inline-block;
    padding: 3px 8px;
    background: #f0f0f0;
    color: #666;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

/* フォントプレビューテキスト */
.font-preview {
    flex: 1;
    text-align: center;
    padding: 0 30px;
    cursor: pointer;
}

.font-card.grid-view .font-preview {
    padding: 0;
    text-align: left;
    width: 100%;
}

.preview-text {
    font-size: 48px;
    font-weight: 400;
    line-height: 1.2;
    color: #333;
    transition: all 0.2s ease;
    word-break: break-all;
}

.font-card.grid-view .preview-text {
    font-size: 56px;
}

/* モーダル */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: 60px;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal.show .modal-content {
    transform: scale(1);
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: white;
    transition: all 0.2s ease;
    z-index: 2001;
    backdrop-filter: blur(10px);
    font-size: 24px;
}

.close-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 40px;
}

.modal-font-name {
    font-size: 24px;
    font-weight: 600;
    color: #333;
    flex: 1;
    margin: 0;
}

.modal-font-preview {
    font-size: 64px;
    margin-bottom: 40px;
    text-align: center;
    color: #333;
    line-height: 1.2;
    word-break: break-all;
    padding: 40px 0;
    border-top: 1px solid #e5e5e5;
    border-bottom: 1px solid #e5e5e5;
}

.modal-controls {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
}

.modal-control-group {
    flex: 1;
}

.modal-control-label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 8px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-text-input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    color: #333;
}

.modal-text-input:focus {
    outline: none;
    border-color: #007AFF;
}

.modal-size-slider {
    width: 100%;
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    outline: none;
    appearance: none;
    cursor: pointer;
    -webkit-appearance: none;
}

.modal-size-slider::-webkit-slider-thumb {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}

.modal-size-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    background: #000;
}

.modal-size-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #333;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.modal-size-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    background: #000;
}

.modal-size-slider::-moz-range-track {
    height: 4px;
    background: #ddd;
    border-radius: 2px;
    border: none;
}

.modal-info {
    margin-bottom: 30px;
}

.modal-section {
    margin-bottom: 30px;
}

.modal-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

.modal-description {
    font-size: 14px;
    color: #666;
    line-height: 1.6;
    margin-bottom: 20px;
}

.modal-meta {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.meta-item {
    flex: 1;  /* 均等配分 */
    min-width: 0;  /* テキストが長い場合の折り返し対応 */
}

.meta-item.full-width {
    flex: 2;  /* コメントは2倍の幅 */
}

.meta-label {
    font-size: 11px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.meta-value {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    word-break: break-word;  /* 長い単語の折り返し */
}

.comment-value {
    font-size: 13px;
    color: #666;
    line-height: 1.6;
    word-break: break-word;  /* 長いテキストの折り返し */
}

.designer-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.designer-icon svg {
    width: 26px;
    height: 26px;
    color: #999;
}

.designer-photo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.brand-logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: white;
    padding: 4px;
    flex-shrink: 0;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-icon svg {
    width: 26px;
    height: 26px;
    color: #999;
}

.modal-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    padding: 4px 10px;
    background: #f0f0f0;
    color: #666;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

/* 利用方法 */
.use-section {
    border-top: 1px solid #e5e5e5;
    padding-top: 24px;
}

.use-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.use-option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    text-decoration: none;
    color: #333;
    border-radius: 8px;
    border: 1px solid #333;
    transition: all 0.2s ease;
}

.use-option:hover {
    background: #f5f5f5;
}

.use-option-left {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.use-option-name {
    font-size: 13px;
    font-weight: 500;
}

.use-option-note {
    font-size: 12px;
    color: #999;
}

.use-option-arrow {
    font-size: 14px;
    color: #999;
    transition: color 0.2s ease;
}

.use-option:hover .use-option-arrow {
    color: #333;
}

/* OMF = primary */
.use-option-primary {
    background: #333;
    color: white;
    border-color: #333;
}

.use-option-primary:hover {
    background: #222;
    border-color: #222;
}

.use-option-primary .use-option-note {
    color: rgba(255, 255, 255, 0.6);
}

.use-option-primary .use-option-arrow {
    color: rgba(255, 255, 255, 0.4);
}

.use-option-primary:hover .use-option-arrow {
    color: white;
}

/* Tablet */
@media (max-width: 1024px) {
    .header {
        padding: 20px 30px;
    }

    .font-section {
        padding: 30px;
    }

    .content-header {
        padding: 20px 30px;
    }

    .font-grid.grid-view {
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 30px;
    }

    .modal-content {
        padding: 40px;
    }
}

/* Keyboard focus styles */
.category-btn:focus-visible,
.filter-select:focus-visible,
.view-btn:focus-visible,
.sidebar-toggle:focus-visible,
.action-btn:focus-visible,
.close-btn:focus-visible {
    outline: 2px solid #007AFF;
    outline-offset: 2px;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 16px 24px;
    }

    .logo-image {
        content: url('../images/logo/OMF-zukan-sp.png');
        height: 40px;
    }

    .nav {
        gap: 12px;
    }

    .nav-left {
        gap: 12px;
    }

    .search-container {
        flex: 1;
        max-width: none;
        min-width: 0;
    }

    .main-content.sidebar-open {
        margin-left: 0;
    }

    .sidebar {
        width: 100%;
    }

    .content-header {
        padding: 16px 24px;
    }

    /* フィルターボタン: アイコンのみ */
    .sidebar-toggle {
        width: 40px;
        height: 40px;
        padding: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-toggle span {
        display: none;
    }

    .sidebar-toggle svg {
        width: 18px;
        height: 18px;
    }

    /* List/Grid切り替えボタンを非表示 */
    .view-modes {
        display: none;
    }

    .font-section {
        padding: 24px;
    }

    .font-grid.grid-view {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .font-preview-section {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .font-info {
        flex: none;
        width: 100%;
        padding-right: 0;
    }

    .font-preview {
        padding: 0;
        text-align: left;
        width: 100%;
    }

    .preview-text {
        font-size: 32px;
    }

    .modal-content {
        padding: 30px;
    }

    .modal-meta {
        flex-wrap: wrap;
        gap: 16px;  /* スマホ版は少し狭く */
    }

    .meta-item {
        flex: 0 0 calc(50% - 8px);  /* ギャップ16pxに対応 */
    }

    .meta-item.full-width {
        flex: 0 0 100%;  /* コメントは下段フル幅 */
        margin-top: 4px;  /* 上段との間隔 */
    }

    .modal-font-preview {
        font-size: 40px;
    }

    .close-btn {
        top: 10px;
        right: 10px;
    }
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #f8f8f8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.loading-screen.hidden {
    opacity: 0;
    visibility: hidden;
}

.loading-image {
    max-width: 200px;
    width: 60%;
    height: auto;
    margin-bottom: 30px;
    animation: fadeInOut 2s ease-in-out infinite;
}

.loading-text {
    font-size: 16px;
    color: #666;
    font-weight: 500;
    margin-top: 20px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top: 3px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes fadeInOut {
    0%, 100% {
        opacity: 0.6;
    }
    50% {
        opacity: 1;
    }
}

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