:root {
    --bg-color: #ffffff;
    --text-color: #1a1a1a;
    --secondary-text: #666666;
    --border-color: #000000;
    --hover-bg: #000000;
    --hover-text: #ffffff;
    --card-shadow: none;
    --hover-bg-soft: #e3e8ee;
    --soft-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    --float-shadow: 0 15px 40px rgba(0, 0, 0, 0.1);
}

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

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    display: flex;
    justify-content: center;
    min-height: 100vh;
    padding: 80px 20px;
    letter-spacing: 0.02em;
}

.container {
    width: 100%;
    max-width: 440px;
    text-align: center;
}

header {
    margin-bottom: 60px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 50px;
    gap: 15px;
    position: relative;
    /* Support absolute positioning for logo */
}

.header-home-link {
    color: #888;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    transition: all 0.3s ease;
    padding: 10px;
    border-radius: 20px;
    flex: 1;
    text-align: left;
    white-space: nowrap;
}

.header-home-link:hover {
    color: var(--text-color);
    background-color: var(--hover-bg-soft);
}

.header-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
}

.header-icon-link,
.search-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    line-height: 1;
}

.header-icon {
    width: 20px;
    height: 20px;
}

.header-icon-link:hover,
.search-trigger:hover {
    color: var(--text-color);
    background-color: var(--hover-bg-soft);
    transform: translateY(-3px);
}

/* Adjust logo centering */
header .profile-icon {
    margin: 0;
    width: 140px;
    /* Smaller for subpages headers */
    flex-shrink: 0;
    z-index: 10;
    /* Ensure logo is above other elements if needed */
}

/* PC Stacked Layout */
@media screen and (min-width: 769px) {
    header {
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 40px 0 20px;
        gap: 30px;
        margin-bottom: 80px;
        position: static;
        min-height: auto;
    }

    header .profile-icon {
        width: 180px;
        /* Enlarge logo for brand presence */
        margin-bottom: 10px;
    }

    .header-home-link {
        display: none;
        /* Hide on PC stack for clean center placement */
    }

    .header-actions {
        width: 100%;
        justify-content: center;
        gap: 20px;
        flex: none;
    }

    .language-switcher {
        margin-right: 15px;
        /* Add more space between lang selector and SNS icons */
    }
}

/* Mobile Header Adjustment */
/* Mobile-only utility */
.sp-only {
    display: none;
}


.profile-icon {
    width: 200px;
    /* Increased width to accommodate logo */
    margin: 0 auto 20px;
    border-radius: 0;
    overflow: hidden;
}

.profile-icon img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: contain;
    /* Removed grayscale filter to show original colors as requested */
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.08));
}

h1 {
    font-size: 1.5rem;
    font-weight: 900;
    text-transform: none;
    letter-spacing: 0.1em;
    color: var(--text-color);
}

.concept-message {
    text-align: center;
    margin-top: -10px;
    margin-bottom: 20px;
}

.concept-title {
    font-size: 1.2rem;
    color: #333;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 0.05em;
}

.concept-text {
    font-size: 0.85rem;
    color: #666;
    letter-spacing: 0.1em;
    line-height: 1.6;
}

.links {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.link-button {
    display: block;
    background-color: var(--bg-color);
    color: var(--text-color);
    text-decoration: none;
    padding: 20px;
    border: 1px solid #f0f0f0;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.95rem;
    text-transform: uppercase;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--soft-shadow);
}

.link-button:hover {
    background-color: var(--hover-bg-soft);
    color: var(--text-color);
    transform: translateY(-3px);
    box-shadow: var(--float-shadow);
}

.link-button:active {
    transform: scale(0.98);
}

/* Subpage & Footer Styles */
.content-area {
    background-color: var(--bg-color);
    padding: 40px 30px;
    border: 1px solid var(--border-color);
    border-radius: 0;
    margin-bottom: 40px;
    text-align: left;
}

h2 {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 25px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.placeholder-text {
    color: var(--secondary-text);
    font-size: 0.9rem;
    line-height: 1.8;
    text-align: center;
}

.page-content p {
    font-size: 0.95rem;
    line-height: 1.8;
    margin-bottom: 1.5rem;
    color: var(--text-color);
}

.page-content strong {
    display: block;
    margin-top: 2rem;
    color: var(--text-color);
    font-weight: 800;
}

.back-button {
    display: inline-block;
    margin-top: 30px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 2px solid var(--text-color);
    padding-bottom: 4px;
    transition: opacity 0.2s;
}

.back-button:hover {
    background-color: var(--hover-bg-soft);
    color: var(--text-color);
    opacity: 1;
}

.top-back-btn {
    display: inline-flex;
    align-items: center;
    color: #888;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 25px;
    padding: 8px 12px;
    border-radius: 20px;
    transition: all 0.3s ease;
    align-self: flex-start;
}

.top-back-btn:hover {
    background-color: var(--hover-bg-soft);
    color: var(--text-color);
    transform: translateX(-5px);
}

footer {
    margin-top: 80px;
    padding-top: 40px;
    border-top: 1px solid #eeeeee;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 25px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--secondary-text);
    text-decoration: none;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--text-color);
}

.copyright {
    font-size: 0.7rem;
    color: #999999;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

/* Breadcrumbs Styles */
.breadcrumbs {
    margin-bottom: 25px;
    text-align: left;
}

.breadcrumbs ul {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.breadcrumbs li {
    font-size: 0.8rem;
    color: #888;
    display: flex;
    align-items: center;
}

.breadcrumbs li a {
    color: #888;
    text-decoration: none;
    transition: color 0.2s;
}

.breadcrumbs li a:hover {
    color: var(--text-color);
}

.breadcrumbs li:not(:last-child)::after {
    content: "/";
    margin-left: 8px;
    font-size: 0.7rem;
    opacity: 0.5;
}

/* News Section Styles */
.news {
    margin-top: 60px;
    text-align: left;
}

.news h3 {
    font-size: 1rem;
    font-weight: 900;
    text-align: center;
    letter-spacing: 0.2em;
    margin-bottom: 30px;
}

.news ul {
    list-style: none;
    padding: 0;
}

.news li {
    background-color: #ffffff;
    padding: 20px 15px;
    border-radius: 12px;
    border: 1px solid #f0f0f0;
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    transition: all 0.3s ease;
    cursor: default;
    box-shadow: var(--soft-shadow);
}

.news li:hover {
    background-color: #ffffff;
    /* Keep white background on hover for cards */
    transform: translateY(-2px);
    box-shadow: var(--float-shadow);
}

.news .date {
    font-size: 0.8rem;
    color: var(--secondary-text);
    flex-shrink: 0;
    min-width: 80px;
}

.news .title {
    font-size: 0.85rem;
    color: var(--text-color);
    line-height: 1.4;
}

@media (max-width: 480px) {
    .news li {
        flex-direction: column;
        gap: 5px;
    }
}

/* Article List Styles */
.article-list {
    list-style: none;
    padding: 0;
}

.article-list li {
    border-bottom: 1px solid #eeeeee;
}

.article-list li:first-child {
    border-top: 1px solid #eeeeee;
}

.article-list a {
    display: block;
    padding: 20px 15px;
    color: var(--text-color);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 700;
    transition: all 0.2s ease;
}

.article-list a:hover {
    background-color: var(--hover-bg-soft);
    color: var(--text-color);
}

.article-list a::after {
    content: "→";
    float: right;
    font-weight: 400;
}

/* Article Template Styles */
.article-header {
    margin-bottom: 40px;
    border-bottom: 2px solid var(--text-color);
    padding-bottom: 20px;
}

.article-date {
    font-size: 0.85rem;
    color: var(--secondary-text);
    margin-bottom: 10px;
    font-weight: 700;
}

/* Glossary Styles */
.view-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 30px;
}

.tab-button {
    padding: 12px 24px;
    border-radius: 30px;
    border: none;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    background-color: #f5f5f5;
    color: #999;
}

.tab-button.active {
    background-color: #333;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.tab-button:not(.active):hover {
    background-color: #eeeeee;
    color: #666;
}

.glossary-accordion {
    margin-top: 10px;
}

.glossary-accordion details {
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
}

.glossary-accordion summary {
    padding: 18px 20px;
    font-weight: 800;
    cursor: pointer;
    background-color: var(--bg-color);
    list-style: none;
    /* Hide default arrow */
    position: relative;
    transition: background-color 0.2s;
    font-size: 0.95rem;
    text-align: left;
}

.glossary-accordion summary::-webkit-details-marker {
    display: none;
}

.glossary-accordion summary::after {
    content: "+";
    position: absolute;
    right: 20px;
    font-size: 1.2rem;
    font-weight: 400;
}

.glossary-accordion details[open] summary::after {
    content: "-";
}

.glossary-accordion summary:hover {
    background-color: var(--hover-bg-soft);
}

.category-content {
    padding: 20px;
    background-color: #fafafa;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-top: 1px solid #eeeeee;
}

.term-card {
    background-color: #ffffff;
    padding: 20px;
    border: 1px solid #eeeeee;
    text-align: left;
}

.term-header {
    margin-bottom: 10px;
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
}

.term-name {
    font-size: 1.1rem;
    font-weight: 900;
    color: var(--text-color);
}

.term-reading {
    font-size: 0.75rem;
    color: var(--secondary-text);
}

.term-meaning {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-color);
}

.syllabary-section {
    margin-bottom: 40px;
}

.syllabary-title {
    font-size: 1.2rem;
    font-weight: 900;
    text-align: left;
    padding-bottom: 10px;
    border-bottom: 2px solid #333;
    margin-bottom: 20px;
}

.syllabary-cards {
    display: flex;
    flex-direction: column;
    gap: 15px;
}


.search-trigger {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: #888;
    transition: all 0.3s ease;
    padding: 10px;
    border-radius: 50%;
}

.search-trigger {
    font-size: 1.1rem;
    /* Adjusting emoji size to match SVGs */
}

.search-modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.82);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    justify-content: center;
    align-items: flex-start;
    padding: 100px 20px;
}

.search-content {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.search-header {
    display: flex;
    align-items: center;
    gap: 15px;
}

#search-input {
    width: 100%;
    padding: 15px 25px;
    border-radius: 40px;
    border: none;
    font-size: 1.1rem;
    outline: none;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    font-family: inherit;
}

.close-search {
    background: none;
    border: none;
    color: white;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 5px;
}

#search-results {
    width: 100%;
    max-height: 60vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Scrollbar for search results */
#search-results::-webkit-scrollbar {
    width: 6px;
}

#search-results::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
}

/* Language Switcher */
.language-switcher {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(255, 255, 255, 0.5);
    padding: 2px 8px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    margin-right: 10px;
}

.globe-icon {
    font-size: 0.9rem;
}

#language-selector {
    background: none;
    border: none;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-color);
    cursor: pointer;
    outline: none;
}

#language-selector option {
    background: white;
}

/* Language Specific Fonts */
html:lang(ko) {
    font-family: 'Noto Sans KR', 'Noto Sans JP', sans-serif;
}

html:lang(zh-TW),
html:lang(zh_TW) {
    font-family: 'Noto Sans TC', 'Noto Sans JP', sans-serif;
}

html:lang(zh-CN),
html:lang(zh_CN) {
    font-family: 'Noto Sans SC', 'Noto Sans JP', sans-serif;
}

.search-result-item {
    background-color: white;
    padding: 18px 25px;
    border-radius: 18px;
    text-align: left;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.search-result-item:hover {
    background-color: var(--hover-bg-soft);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.search-result-item a {
    text-decoration: none;
    color: var(--text-color);
    font-size: 1rem;
    font-weight: 700;
    display: block;
}

.no-results {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.95rem;
    text-align: center;
    margin-top: 40px;
    letter-spacing: 0.05em;
}

/* Content switching for articles */
[data-lang] {
    display: none;
}

/* Default to Japanese if no lang class is present (optional, but good for fallback) */
[data-lang="ja"] {
    display: block;
}

/* Toggle visibility based on body class */
body.lang-ja [data-lang="ja"] {
    display: block;
}

body.lang-ja [data-lang="en"],
body.lang-ja [data-lang="zh_TW"],
body.lang-ja [data-lang="ko"],
body.lang-ja [data-lang="zh_CN"] {
    display: none;
}

body.lang-en [data-lang="en"] {
    display: block;
}

body.lang-en [data-lang="ja"] {
    display: none;
}

body.lang-zh_TW [data-lang="zh_TW"] {
    display: block;
}

body.lang-zh_TW [data-lang="ja"] {
    display: none;
}

body.lang-ko [data-lang="ko"] {
    display: block;
}

body.lang-ko [data-lang="ja"] {
    display: none;
}

body.lang-zh_CN [data-lang="zh_CN"] {
    display: block;
}

body.lang-zh_CN [data-lang="ja"] {
    display: none;
}

/* Mobile Header Adjustment */
@media screen and (max-width: 768px) {
    .sp-only {
        display: block;
    }

    header {
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        gap: 15px !important;
        margin-bottom: 40px !important;
        min-height: auto !important;
        position: static !important;
        padding-top: 20px !important;
    }

    .header-home-link {
        display: none !important;
    }

    .header-actions {
        width: 100% !important;
        justify-content: center !important;
        gap: 15px !important;
        order: 1 !important;
        display: flex !important;
    }

    header .profile-icon {
        position: static !important;
        transform: none !important;
        width: 120px !important;
        margin: 10px 0 20px !important;
        order: 2 !important;
    }

    .concept-message {
        order: 3 !important;
        margin-top: 0 !important;
    }

    .concept-text {
        line-height: 1.8 !important;
    }

    .header-icon {
        width: 18px !important;
        height: 18px !important;
    }

    .globe-icon {
        display: none !important;
    }

    .language-switcher {
        padding: 2px 8px !important;
        margin-right: 0 !important;
        gap: 2px !important;
    }

    #language-selector {
        font-size: 0.8rem !important;
    }
}

/* Article Navigation Styles */
.article-navigation {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 50px;
    padding-top: 30px;
    border-top: 1px solid #efefef;
    gap: 15px;
}

.nav-prev,
.nav-next {
    flex: 1;
    font-size: 0.85rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--secondary-text);
    transition: all 0.3s ease;
}

.nav-prev:hover,
.nav-next:hover {
    color: var(--text-color);
}

.nav-prev {
    text-align: left;
}

.nav-next {
    text-align: right;
}

.share-section {
    margin-top: 50px;
    padding: 30px;
    background: #fdfdfd;
    border-radius: 20px;
    text-align: center;
    border: 1px dashed #ddd;
}

.share-section p {
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--secondary-text);
}