body {
    font-family: "Noto Sans JP", "Noto Sans", sans-serif;
    font-optical-sizing: auto;
    font-size: 15px;
    background-color: #ededed;
    color: #444;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
}

h1,
h2,
h3,
h4,
h5,
h6,
p,
blockquote,
pre {
    margin: 0;
    padding: 0;
}

pre,
code {
    margin-top: 10px;
    font-family: "M Plus 1 Code", monospace;
    font-size: 18px;
    letter-spacing: 0.08em;
}

h1 {
    margin-top: 20px;
    margin-bottom: 10px;
    font-weight: 400;
    font-size: 32px;
}

h1:first-of-type {
    margin-top: 0;
}

label {
    display: block;
    margin-top: 10px;
    margin-bottom: 10px;
    font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"] {
    display: block;
    border-radius: 4px;
    padding: 12px 8px;
    border: 1px solid #bbb;
    font-size: 16px;
    min-width: 300px;
    height: 50px;
    box-sizing: border-box;
}

button,
.button-standard {
    display: block;
    border-radius: 4px;
    border: none;
    background-color: #8164f6;
    color: white;
    padding: 12px 8px;
    margin-top: 20px;
    min-width: 300px;
    box-sizing: border-box;
    font-size: 20px;
    height: 50px;
    font-weight: 400;
    text-decoration: none;
    text-align: center;
}

.button-standard.brand {
    background-color: #4a7f2d;
}

.button-standard.success {
    background-color: #4bb44b;
}

.button-standard.fail {
    background-color: #b44b4b;
}

.margin-top {
    margin-top: 30px;
}

a.button-standard {
    width: 300px;
}

button:hover {
    background-color: #917aef;
}

button:active {
    background-color: #6047c5;
}

button:focus {
    outline: 2px solid #472da6;
}

div {
    box-sizing: border-box;
}

.content {
    padding: 50px;
}

.review-card {
    margin-top: 10px;
    min-height: 200px;
    text-align: center;
}

.review-form {
    background-color: transparent;
}

.review-form-contents {
    padding: 30px !important;
    border: 2px solid red;
    border-radius: 5px;
}

.review-form-contents.kanji {
    background-color: #fcefc5;
    border-color: #e7b40e;
}

.review-form-contents.kanji h1,
.review-form-contents.kanji button {
    background-color: #e7b40e;
}

.review-form-contents button {
    height: 70px;
    font-size: 24px;
}

.review-form-contents.vocabulary {
    background-color: #fcc5f4;
    border-color: #e70eca;
}

.review-form-contents.vocabulary h1,
.review-form-contents.vocabulary button {
    background-color: #e70eca;
}

.review-form-contents .review-type {
    margin-bottom: 20px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 4px;
    font-size: 16px;
}

.review-form-contents.kanji .review-type {
    color: #e7b40e;
}

.review-form-contents.vocabulary .review-type {
    color: #e70eca;
}

.review-card input[type="text"] {
    background-color: rgba(255, 255, 255, 0.8);
}

.review-card h1 {
    text-align: center;
    font-size: 64px;
    font-weight: 800;
    border-radius: 20px;
    background-color: #bcbcbc;
    padding: 40px 80px;
    display: inline-block;
    color: white;
}

.review-card .answer-box {
    margin: 0 auto;
    padding: 20px 0 0;
    display: flex;
    flex-direction: column;
}

.review-card .answer-box label {
    text-align: left;
}

.review-card .answer-box input {
    height: 100px;
    font-size: 36px;
    padding-left: 16px;
    padding-right: 16px;
}

.navigation {
    height: 70px;
    background-color: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid #ccc;
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.05);
    position: sticky;
    top: 0;
    padding: 0 50px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.navigation .logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo img {
    display: inline-block;
    margin: 0;
    padding: 0;
    height: 40px;
}

.logo a {
    text-decoration: none;
}

.navigation-items {
    padding: 0;
    margin: 0;
    display: flex;
    gap: 10px;
    align-items: center;
}

.navigation-items .navigation-item {
    font-size: 16px;
    text-decoration: none;
    text-indent: 0;
    list-style: none;
    height: 100%;
}

.navigation-items .navigation-profile-summary {
    display: flex;
    align-items: center;
    gap: 5px;
}

.navigation-items .navigation-profile-picture {
    width: 25px;
    height: 25px;
    border: 1px solid #000;
    border-radius: 50%;
    margin-top: 3px;
}

.navigation-items .user-name {
    text-decoration: none;
    text-indent: 0;
    list-style: none;
    font-weight: 600;
}

.navigation-item a {
    text-decoration: none;
    color: #555;
    box-sizing: border-box;
    padding: 7px 10px;
    border: 1px solid transparent;
    border-radius: 8px;
    display: block;
    height: 100%;
}

.navigation-item a:hover {
    border: 1px solid #8164f6;
    color: #8164f6;
}

.upcoming-reviews {
    list-style: none;
    padding-left: 0;
}

.upcoming-review {
    text-indent: 0;
    height: 30px;
    margin-top: 10px;
    display: flex;
    gap: 5px;
    align-items: center;
}

.upcoming-review:first-child {
    margin-top: 0;
}

.upcoming-review-date {
    width: 120px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #8164f6;
    color: white;
    border-radius: 5px;
    height: 30px;
}

.upcoming-review-count,
.upcoming-review-time {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
    height: 30px;
    border-radius: 5px;
    background-color: #ddd;
    padding-left: 5px;
    padding-right: 5px;
}

.upcoming-review-time {
    margin-left: 0;
}

.front-page-hero {
    display: flex;
    gap: 20px;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.front-page-hero img {
    height: 450px;
    box-shadow: 0 0 400px 20px rgba(42, 73, 17, 0.5);
    border-radius: 10px;
}

.front-page-hero h1 {
    margin-bottom: 0;
    font-size: 72px;
    font-weight: 600;
}

.front-page-hero p {
    margin-top: 10px;
}

.front-page-hero .button-standard {
    margin-top: 0;
    height: 60px;
    font-size: 24px;
    font-weight: 800;
}

input[type="file"] {
    outline: none;
    padding: 4px;
    margin: -4px;
}

input[type="file"]:focus-within::file-selector-button,
input[type="file"]:focus::file-selector-button {
    outline: 2px solid #0964b0;
    outline-offset: 2px;
}

input[type="file"]::before {
    top: 16px;
}

input[type="file"]::after {
    top: 14px;
}

/* ------- From Step 2 ------- */

input[type="file"] {
    position: relative;
}

input[type="file"]::file-selector-button {
    width: 120px;
    color: transparent;
}

input[type="file"]::before {
    position: absolute;
    pointer-events: none;
    left: 40px;
    color: #0964b0;
    content: "Upload File";
}

input[type="file"]::after {
    position: absolute;
    pointer-events: none;
    left: 16px;
    height: 20px;
    width: 20px;
    content: "";
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%230964B0'%3E%3Cpath d='M18 15v3H6v-3H4v3c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2v-3h-2zM7 9l1.41 1.41L11 7.83V16h2V7.83l2.59 2.58L17 9l-5-5-5 5z'/%3E%3C/svg%3E");
}

input[type="file"]::file-selector-button {
    border-radius: 4px;
    padding: 0 16px;
    height: 40px;
    cursor: pointer;
    background-color: white;
    border: 1px solid rgba(0, 0, 0, 0.16);
    box-shadow: 0px 1px 0px rgba(0, 0, 0, 0.05);
    margin-right: 16px;
    transition: background-color 200ms;
}

input[type="file"]::file-selector-button:hover {
    background-color: #f3f4f6;
}

input[type="file"]::file-selector-button:active {
    background-color: #e5e7eb;
}

.kanji-level {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
    margin-bottom: 20px;
    align-items: stretch;
}

.kanji-level a {
    text-decoration: none;
    align-self: stretch;
    flex: 0 0 auto;
}

.kanji-level .kanji-level-kanji {
    width: 100px;
    min-height: 100px;
    padding: 10px;
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kanji-level .kanji-level-kanji:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
}

.kanji-level .kanji-level-kanji .value {
    font-weight: 500;
    font-size: 40px;
    margin-bottom: 4px;
    line-height: 1.1;
}

.kanji-level .kanji-level-kanji .meaning {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0.85;
}

.kanji-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.kanji-type-label {
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 4px;
    color: #666;
    text-transform: uppercase;
    padding-left: 4px;
}

.kanji-type-label + a,
.kanji-type-label + .kanji-level-kanji {
    margin-top: 0;
}

.kanji-detail h1 {
    font-size: 90px;
}

.kanji-detail h2 {
    font-size: 30px;
    font-weight: 600;
    margin-bottom: 10px;
    margin-top: 20px;
}

.kanji-detail p {
    font-size: 24px;
    font-weight: 400;
}

.separator,
.example-word-separator {
    display: inline-block;
    margin-left: 10px;
    margin-right: 10px;
    color: #939393;
    font-weight: 400;
}

.search-logo {
    display: flex;
    justify-content: center;
    align-items: center;
}

.search-logo img {
    height: 150px;
    padding: 20px 0px;
}

.search-bar {
    display: flex;
    align-items: center;
    flex-direction: column;
}

.search-bar input[type="text"] {
    font-size: 20px;
    padding: 18px 8px;
    min-width: 300px;
    height: 30px;
}

.search-bar button {
    display: block;
    border-radius: 4px;
    border: none;
    background-color: #8164f6;
    color: white;
    padding: 1px 8px;
    min-width: 100px;
    box-sizing: border-box;
    font-size: 20px;
    height: 30px;
    font-weight: 400;
    text-decoration: none;
    text-align: center;
}

.search-bar p {
    margin-top: 10px;
}

.tree-roots {
    display: flex;
    gap: 5px;
    margin-top: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tree-link {
    text-decoration: none;
    align-self: stretch;
    width: 100px;
    height: 100px;
}

.tree-root {
    width: 100px;
    height: 100%;
    padding: 10px;
    background-color: #666;
    border: 1px solid #333;
    font-size: 32px;
    color: white;
    align-content: center;
    text-align: center;
}

.tree-root.tree-root-red {
    background-color: #ff6666;
}

.tree-root.tree-root-orange {
    background-color: #ffbd55;
}

.tree-root.tree-root-green {
    background-color: #9de24f;
}

.tree-root.tree-root-blue {
    background-color: #87cefa;
}

.tree-root.tree-root-violet {
    background-color: #a64dc2;
}

.glossary li {
    margin-bottom: 10px;
}

.image-block {
    text-align: center;
    position: relative;
}

.image-block h1 {
    font-size: 20px;
    font-weight: bold;
}

.image-block img {
    height: 200px;
    border-radius: 30px;
    display: inline-block;
    margin: auto;
}

.dropdown {
    position: relative;
    height: 100%; /* Ensures it matches nav height */
    display: flex;
    align-items: center; /* Vertically center its contents */
}

.dropdown-content {
    display: none;
    position: absolute;
    top: 100%; /* directly below the parent */
    left: 0;
    background-color: #fcfcfc;
    min-width: 200px;
    padding: 8px 0;
    box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    border-radius: 6px;
}

.dropdown-content a {
    display: block;
    padding: 10px 16px;
    text-decoration: none;
    color: #444;
    white-space: nowrap;
    border: none;
    border-radius: 0;
}

.dropdown-content a:hover {
    color: #f5f5f5;
    background-color: #8164f6;
    border: none;
    border-radius: 0;
}

.dropdown:hover .dropdown-content {
    display: block;
}

#review-result-container {
    margin-top: 20px;
}

.review-result {
    border: none;
    color: white;
    padding: 0;
    margin-bottom: 20px;
    font-size: 20px;
    background-color: #ffffff;
}

.review-result.success > summary {
    background: linear-gradient(180deg, #65cc65 0%, #4bb44b 100%), #d9d9d9;
}

.review-result.fail > summary {
    background: linear-gradient(180deg, #cc6565 0%, #b44b4b 100%), #d9d9d9;
}

.review-result.success .review-result-contents {
    border: 1px solid #4bb44b;
    color: #464646;
}

.review-result.fail .review-result-contents {
    border: 1px solid #cc6565;
    color: #464646;
}

.review-result > summary {
    border-radius: 5px;
    list-style: none;
    height: 49px;
    cursor: grab;
    user-select: none;

    color: #fff;
    text-box-trim: both;
    text-box-edge: cap alphabetic;
    font-family: "Noto Sans JP";
    font-size: 24px;
    font-style: normal;
    font-weight: 700;
    line-height: normal;
    align-items: center;
    padding-bottom: 1px; /* Line height adjustment */
}

.review-result[open] > summary {
    border-radius: 5px 5px 0 0;
}

.review-result-title-bar {
    display: flex;
    padding: 0px 10px;
    gap: 10px;
}

.review-result-contents {
    padding: 20px;
    border-radius: 0 0 5px 5px;
    border-top-width: 0;
    text-align: left;
}

.table {
    display: flex;
    flex-direction: column;
    border: 1px solid #ccc;
    font-size: 14px;
    border-radius: 4px;
    overflow: hidden;
    margin-top: 20px;
}

.row {
    display: grid;
    grid-template-columns:
        200px /* Level Name */
        2fr /* Roots */
        2fr /* Compounds */
        2fr /* Corrupted Roots */
        2fr; /* Prerequisites */
    border-bottom: 1px solid #ccc;
}

.table-header {
    font-weight: bold;
    background: #f0f0f0;
}

.table-row:nth-child(even) {
    background-color: #fafafa;
}

.cell {
    padding: 0.5rem;
    border-right: 1px solid #ddd;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: flex-start;
}

.cell:last-child {
    border-right: none;
}

.kanji {
    background-color: #eee;
    padding: 2px 4px;
    border-radius: 4px;
    white-space: nowrap;
    align-self: flex-start;
    font-size: 16px;
}

.root {
    background-color: #e7b40e;
    color: white;
}
.compound {
    background-color: #8164f6;
    color: white;
}
.corrupted-root {
    background-color: #b44b4b;
    color: white;
}
.prerequisite {
    background-color: #777;
    color: white;
}

.level-count {
    color: #777;
    margin-left: 5px;
}

.loading {
    position: relative;
    overflow: visible;
    user-select: none;
    cursor: wait;
}

.loading::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.15);
    filter: blur(20px);
    z-index: 10;
}

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 24px;
    height: 24px;
    border: 6px solid rgba(0, 0, 0, 0.5);
    border-top-color: #ffffff; /* the spinning segment */
    border-radius: 50%;
    animation: spin 1.25s linear infinite;
    z-index: 11;
}

@keyframes spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

.progress-bar {
    position: relative;
    width: 100%;
    height: 20px;
    background: #d0d0d0;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    transition: width 0.3s, left 0.3s;
}

.progress-fill.readings {
    left: 0;
    background-color: #e7b40e;
}

.progress-fill.meanings {
    background-color: #e70eca;
}
