:root {
    --bg: #ffffff;
    --study-bg: #f5f8fc;
    --surface: #ffffff;
    --surface-soft: #f7faf9;
    --text: #15232d;
    --muted: #71808a;
    --line: #dfe8e5;
    --line-strong: #c8d8d3;
    --mint: #198f78;
    --mint-dark: #116c5a;
    --mint-soft: #e8f3ef;
    --red: #ec6658;
    --red-soft: #fff0ed;
    --yellow: #d9931e;
    --yellow-soft: #fff6dd;
    --green: #34965b;
    --green-soft: #e8f6ed;
    --blue: #4d6d99;
    --blue-soft: #edf2fa;
    --shadow-soft: 0 14px 34px rgba(21, 35, 45, 0.06);
    --shadow-card: 0 18px 45px rgba(21, 35, 45, 0.1);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --content-width: 1180px;
    --font-body: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --font-display: Georgia, "Times New Roman", serif;
}

* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    background: var(--bg);
}

body {
    min-width: 320px;
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.5;
}

button,
input,
select {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button {
    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid rgba(77, 109, 153, 0.32);
    outline-offset: 3px;
}

.is-hidden {
    display: none !important;
}

.site-header,
.study-header {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
}

.site-header {
    position: sticky;
    z-index: 10;
    top: 0;
}

.header-inner,
.study-header-inner {
    display: flex;
    width: min(var(--content-width), calc(100% - 48px));
    min-height: 78px;
    margin: 0 auto;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: var(--mint);
    font-family: var(--font-display);
    font-size: 21px;
    font-weight: 700;
}

.brand-name {
    font-family: var(--font-display);
    font-size: 27px;
    font-weight: 700;
    letter-spacing: -0.04em;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.main-content {
    width: min(var(--content-width), calc(100% - 48px));
    margin: 0 auto;
    padding: 66px 0 96px;
}

.intro-section {
    display: grid;
    gap: 22px;
    margin-bottom: 42px;
}

.intro-section h1,
.section-heading h2,
.creation-section h2,
.study-context h1,
.study-complete h2 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    letter-spacing: -0.035em;
}

.intro-section h1 {
    max-width: 720px;
    font-size: clamp(40px, 5vw, 62px);
    line-height: 0.98;
}

.intro-section p,
.section-heading p,
.creation-section p,
.empty-state p,
.setup-notice p {
    margin: 14px 0 0;
    color: var(--muted);
}

.intro-section p {
    max-width: 570px;
    font-size: 18px;
}

.intro-rule {
    width: 100%;
    height: 2px;
    background: var(--mint);
}

.section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 18px;
}

.section-heading h2,
.creation-section h2 {
    font-size: 28px;
    line-height: 1.1;
}

.summary-section,
.boxes-section {
    margin-bottom: 44px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.summary-item {
    position: relative;
    min-height: 142px;
    padding: 26px 28px 24px;
}

.summary-item + .summary-item::before {
    position: absolute;
    top: 26px;
    bottom: 26px;
    left: 0;
    width: 1px;
    background: var(--line);
    content: "";
}

.summary-label,
.box-count-label {
    display: block;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.summary-number {
    display: block;
    margin-top: 10px;
    font-family: var(--font-display);
    font-size: 50px;
    line-height: 1;
}

.summary-item.color-red .summary-number,
.box-count.color-red .box-count-number {
    color: var(--red);
}

.summary-item.color-yellow .summary-number,
.box-count.color-yellow .box-count-number {
    color: var(--yellow);
}

.summary-item.color-green .summary-number,
.box-count.color-green .box-count-number {
    color: var(--green);
}

.box-list {
    display: grid;
    gap: 18px;
}

.box-card {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--shadow-soft);
}

.box-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 22px 28px;
    border-bottom: 1px solid var(--line);
    background: var(--mint-soft);
}

.box-card-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 27px;
    line-height: 1.1;
}

.box-card-languages {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.box-card-body {
    display: block;
    gap: 28px;
    align-items: center;
    padding: 24px 28px 26px;
}

.box-counts {
    display: grid;
    grid-template-columns: repeat(4, minmax(80px, 1fr));
    gap: 16px;
}

.box-count {
    min-width: 0;
}

.box-count-number {
    display: block;
    margin-top: 3px;
    font-size: 25px;
    font-weight: 700;
}

.box-count:first-child .box-count-number {
    color: var(--text);
}

.box-count-actions {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.box-count-actions .button-start {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 12px;
}

.box-count-color .box-count-label {
    color: currentColor;
}

.box-count-color.color-red {
    color: var(--red);
}

.box-count-color.color-yellow {
    color: var(--yellow);
}

.box-count-color.color-green {
    color: var(--green);
}

.button,
.text-button,
.back-button {
    border: 0;
    font-weight: 700;
    transition: transform 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease;
}

.button {
    min-height: 44px;
    padding: 10px 17px;
    border-radius: var(--radius-sm);
    font-size: 14px;
}

.button:hover:not(:disabled) {
    transform: translateY(-1px);
}

.button-primary {
    color: white;
    background: var(--mint);
}

.button-primary:hover:not(:disabled) {
    background: var(--mint-dark);
}

.button-secondary,
.button-continue {
    color: var(--mint-dark);
    border: 1px solid var(--mint);
    background: white;
}

.button-secondary:hover:not(:disabled),
.button-continue:hover:not(:disabled) {
    background: var(--mint-soft);
}

.button-start {
    color: var(--mint-dark);
    border: 1px solid var(--line-strong);
    background: white;
}

.button-start:hover:not(:disabled) {
    border-color: var(--mint);
    background: var(--mint-soft);
}

.button:disabled {
    opacity: 0.44;
}

.text-button {
    padding: 4px 0;
    color: var(--mint-dark);
    background: transparent;
    font-size: 14px;
}

.text-button:hover {
    color: var(--text);
}

.creation-section {
    margin: 0 0 44px;
    padding: 26px 28px 30px;
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px 20px;
    align-items: end;
}

.card-form-grid {
    grid-template-columns: 1fr 1fr;
}

.field-wide {
    grid-column: 1 / -1;
}

.field {
    display: grid;
    gap: 8px;
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.field input,
.field select {
    width: 100%;
    min-height: 48px;
    padding: 10px 13px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: white;
}

.field input::placeholder {
    color: #9aa7ad;
}

.form-actions {
    display: flex;
    justify-content: end;
    gap: 9px;
}

.empty-state,
.setup-notice {
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    background: var(--surface-soft);
    text-align: center;
}

.empty-state {
    padding: 52px 24px;
}

.empty-mark,
.notice-icon,
.complete-mark {
    display: grid;
    width: 42px;
    height: 42px;
    margin: 0 auto 15px;
    place-items: center;
    border-radius: 50%;
    color: white;
    background: var(--mint);
    font-size: 24px;
    font-weight: 700;
}

.empty-state h3,
.setup-notice h2 {
    margin: 0;
    font-family: var(--font-display);
    font-size: 24px;
}

.empty-state .button {
    margin-top: 22px;
}

.setup-notice {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 18px;
    margin-bottom: 34px;
    padding: 22px 24px;
    text-align: left;
}

.setup-notice .notice-icon {
    margin: 0;
    color: #7d5d19;
    background: var(--yellow-soft);
}

.setup-notice p {
    margin-top: 5px;
}

.setup-notice .notice-detail {
    color: var(--red);
    font-size: 13px;
}

.study-view {
    min-height: 100vh;
    color: var(--text);
    background: var(--study-bg);
}

.study-header {
    background: white;
}

.back-button {
    display: inline-flex;
    min-height: 44px;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    color: var(--blue);
    background: transparent;
    font-size: 15px;
}

.back-button span:first-child {
    font-size: 27px;
    font-weight: 400;
    line-height: 1;
}

.study-context {
    display: flex;
    align-items: center;
    gap: 14px;
}

.study-context h1 {
    font-size: 25px;
}

.study-color {
    display: inline-flex;
    min-height: 28px;
    align-items: center;
    padding: 3px 11px;
    border-radius: 99px;
    font-size: 13px;
    font-weight: 800;
}

.study-color.color-red {
    color: #9f332b;
    background: var(--red-soft);
}

.study-color.color-yellow {
    color: #8f5d0d;
    background: var(--yellow-soft);
}

.study-color.color-green {
    color: #216b3f;
    background: var(--green-soft);
}

.study-main {
    display: flex;
    width: min(920px, calc(100% - 48px));
    min-height: calc(100vh - 79px);
    margin: 0 auto;
    padding: 54px 0 68px;
    flex-direction: column;
    align-items: center;
}

.study-box-name {
    margin-bottom: 18px;
    color: var(--muted);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.flashcard {
    display: flex;
    width: min(800px, 100%);
    min-height: 450px;
    padding: 42px 38px 34px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: white;
    box-shadow: var(--shadow-card);
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.flashcard-side-label {
    min-height: 22px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.flashcard-word {
    display: grid;
    min-height: 180px;
    margin: 8px 0 24px;
    place-items: center;
    color: var(--text);
    font-family: var(--font-display);
    font-size: clamp(54px, 8vw, 94px);
    line-height: 1.02;
    text-align: center;
    overflow-wrap: anywhere;
}

.button-card {
    min-width: 150px;
    color: var(--blue);
    border: 1px solid #99aaca;
    background: white;
}

.button-card:hover {
    background: var(--blue-soft);
}

.study-actions {
    display: grid;
    width: min(800px, 100%);
    grid-template-columns: minmax(130px, 0.78fr) repeat(2, minmax(130px, 1fr));
    gap: 14px;
    margin-top: 28px;
}

.study-actions .button {
    min-height: 58px;
    font-size: 16px;
}

.move-actions {
    display: contents;
}

.move-button.color-red {
    color: #9f332b;
    border: 1px solid #f0b0a9;
    background: var(--red-soft);
}

.move-button.color-yellow {
    color: #8f5d0d;
    border: 1px solid #e8c875;
    background: var(--yellow-soft);
}

.move-button.color-green {
    color: #216b3f;
    border: 1px solid #a4d7b4;
    background: var(--green-soft);
}

.move-button:hover {
    filter: saturate(1.1);
}

.move-button small {
    display: block;
    margin-top: 2px;
    color: currentColor;
    font-size: 11px;
    font-weight: 600;
    opacity: 0.78;
}

.study-progress {
    width: min(800px, 100%);
    margin-top: 34px;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

.progress-track {
    height: 5px;
    margin-bottom: 11px;
    overflow: hidden;
    border-radius: 99px;
    background: #dce4ef;
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: var(--blue);
    transition: width 200ms ease;
}

.study-complete {
    width: min(560px, 100%);
    padding: 52px 28px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: white;
    box-shadow: var(--shadow-soft);
    text-align: center;
}

.study-complete .complete-mark {
    background: var(--green);
}

.study-complete p {
    margin: 11px 0 22px;
    color: var(--muted);
}

.toast {
    position: fixed;
    z-index: 20;
    right: 22px;
    bottom: 22px;
    max-width: min(380px, calc(100% - 44px));
    padding: 12px 16px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
    background: white;
    box-shadow: var(--shadow-soft);
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.toast.is-error {
    color: #9f332b;
    border-color: #f0b0a9;
    background: var(--red-soft);
}

@media (max-width: 820px) {
    .header-inner,
    .study-header-inner,
    .main-content,
    .study-main {
        width: min(100% - 32px, var(--content-width));
    }

    .header-inner {
        min-height: 70px;
    }

    .brand-name {
        font-size: 24px;
    }

    .header-actions .button {
        padding-inline: 12px;
    }

    .main-content {
        padding-top: 46px;
    }

    .box-card-body {
        grid-template-columns: 1fr;
    }

    .study-main {
        min-height: calc(100vh - 71px);
        padding-top: 38px;
    }
}

@media (max-width: 620px) {
    .header-inner,
    .study-header-inner,
    .main-content,
    .study-main {
        width: calc(100% - 24px);
    }

    .header-inner {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
        padding: 14px 0;
    }

    .header-actions {
        width: 100%;
    }

    .header-actions .button {
        flex: 1;
    }

    .intro-section h1 {
        font-size: 45px;
    }

    .summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .summary-item {
        min-height: 118px;
        padding: 20px 18px;
    }

    .summary-item:nth-child(odd)::before {
        display: none;
    }

    .summary-item:nth-child(n + 3) {
        border-top: 1px solid var(--line);
    }

    .summary-number {
        font-size: 40px;
    }

    .box-card-header,
    .box-card-body,
    .creation-section {
        padding-right: 18px;
        padding-left: 18px;
    }

    .box-card-header {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .box-card-title {
        font-size: 24px;
    }

    .box-counts {
        gap: 11px;
    }

    .box-count-label {
        font-size: 11px;
    }

    .box-count-number {
        font-size: 21px;
    }

    .box-count-actions .button {
        width: 100%;
    }

    .form-grid,
    .card-form-grid {
        grid-template-columns: 1fr;
    }

    .field-wide {
        grid-column: auto;
    }

    .form-actions,
    .form-actions .button {
        width: 100%;
    }

    .study-header-inner {
        min-height: 68px;
    }

    .study-context {
        align-items: flex-end;
        flex-direction: column-reverse;
        gap: 2px;
    }

    .study-context h1 {
        max-width: 150px;
        overflow: hidden;
        font-size: 20px;
        text-align: right;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .flashcard {
        min-height: 390px;
        padding: 30px 18px 24px;
    }

    .flashcard-word {
        min-height: 150px;
        font-size: clamp(46px, 16vw, 70px);
    }

    .study-actions {
        grid-template-columns: 1fr 1fr;
        gap: 9px;
        margin-top: 18px;
    }

    .study-actions .button {
        min-height: 54px;
        padding-inline: 8px;
        font-size: 14px;
    }

    .study-actions .button-continue {
        grid-column: 1 / -1;
    }

    .move-button small {
        font-size: 10px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
