:root {
    --apple-blue: #0071e3;
    --apple-gray: #f5f5f7;
    --apple-dark-gray: #86868b;
    --apple-light-gray: #fafafa;
    --apple-border: #d2d2d7;
    --apple-red: #ff3b30;
    --apple-green: #34c759;
    --apple-orange: #ff9500;
    --primary-color: #0071e3;
    --primary-hover: #005bbf;
    --text-color: #1d1d1f;
    --background-color: #ffffff;
    --card-background: #f5f5f7;
    --card-border: #e6e6e6;
    --card-shadow: rgba(0, 0, 0, 0.1);
    --card-content-color: #1d1d1f;
    --correct-color: #34c759;
    --incorrect-color: #ff3b30;
    --hover-bg: #f5f5f7;
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --input-border: #d2d2d7;
    --toggle-bg: #e6e6e6;
    --toggle-active: #34c759;
    --section-bg: #f5f5f7;
    --note-color: #86868b;
    --library-item-bg: #fff;
    --library-item-border: #e6e6e6;
    --secondary-button-bg: #e6e6e6;
    --secondary-button-hover: #d2d2d7;
}

body.dark-mode {
    --primary-color: #0a84ff;
    --primary-hover: #007aff;
    --text-color: #f5f5f7;
    --background-color: #1d1d1f;
    --card-background: #2c2c2e;
    --card-border: #3a3a3c;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --card-content-color: #f5f5f7;
    --correct-color: #30d158;
    --incorrect-color: #ff453a;
    --hover-bg: #3a3a3c;
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --input-border: #3a3a3c;
    --toggle-bg: #3a3a3c;
    --toggle-active: #30d158;
    --section-bg: #2c2c2e;
    --note-color: #98989d;
    --library-item-bg: #3a3a3c;
    --library-item-border: #4a4a4c;
    --secondary-button-bg: #3a3a3c;
    --secondary-button-hover: #4a4a4c;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'SF Pro Display', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
    line-height: 1.5;
    color: var(--text-color);
    background-color: var(--background-color);
    transition: background-color 0.3s, color 0.3s;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    text-align: center;
    margin-bottom: 4rem;
    position: relative;
}
/* Auth controls */
.auth-controls {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--apple-border);
}

.avatar.small {
    width: 28px;
    height: 28px;
}

.user-name {
    font-size: 14px;
    color: var(--apple-dark-gray);
}

.google-btn {
    background: #fff;
    color: #1f1f1f;
    border: 1px solid var(--apple-border);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 8px 14px;
}

.google-btn:hover {
    background: #f7f7f7;
}

.google-icon {
    width: 18px;
    height: 18px;
    display: inline-block;
    background-image: url('data:image/svg+xml,%3Csvg xmlns=%22http://www.w3.org/2000/svg%22 width=%2218%22 height=%2218%22 viewBox=%220 0 18 18%22%3E%3Cg fill=%22none%22 fill-rule=%22evenodd%22%3E%3Cpath fill=%22%234285F4%22 d=%22M17.64 9.204c0-.638-.057-1.252-.163-1.84H9v3.481h4.844a4.14 4.14 0 0 1-1.797 2.716v2.255h2.905c1.7-1.566 2.688-3.872 2.688-6.612Z%22/%3E%3Cpath fill=%22%2334A853%22 d=%22M9 18c2.43 0 4.467-.806 5.956-2.184l-2.905-2.255c-.806.54-1.838.86-3.051.86-2.347 0-4.334-1.586-5.042-3.72H.957v2.336A9 9 0 0 0 9 18Z%22/%3E%3Cpath fill=%22%23FBBC05%22 d=%22M3.958 10.701A5.408 5.408 0 0 1 3.676 9c0-.59.102-1.16.282-1.701V4.963H.957A9 9 0 0 0 0 9c0 1.454.348 2.83.957 4.037l3.001-2.336Z%22/%3E%3Cpath fill=%22%23EA4335%22 d=%22M9 3.58c1.32 0 2.505.455 3.437 1.349l2.58-2.58C13.463.89 11.426 0 9 0A9 9 0 0 0 .957 4.963l3.001 2.336C4.666 5.165 6.653 3.58 9 3.58Z%22/%3E%3C/g%3E%3C/svg%3E');
    background-size: cover;
}

header h1 {
    font-size: 48px;
    font-weight: 600;
    letter-spacing: -0.015em;
    margin-bottom: 0.5rem;
}

header p {
    font-size: 24px;
    color: var(--apple-dark-gray);
    font-weight: 400;
    margin-bottom: 1rem;
}

.site-language {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.site-language label {
    font-size: 14px;
    color: var(--apple-dark-gray);
}

.site-language .apple-select {
    font-size: 14px;
    padding: 6px 25px 6px 10px;
    width: auto;
}

.theme-toggle {
    margin-top: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.theme-label {
    font-size: 14px;
}

main {
    flex: 1;
    display: flex;
    justify-content: center;
}

.screen {
    display: none;
    width: 100%;
    max-width: 800px;
}

.screen.active {
    display: block;
}

.buttons {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    margin-top: 2rem;
}

.apple-button {
    background-color: var(--apple-blue);
    color: white;
    border: none;
    border-radius: 980px;
    padding: 12px 22px;
    font-size: 17px;
    font-weight: 400;
    cursor: pointer;
    min-width: 220px;
    text-align: center;
    transition: all 0.2s;
}

.apple-button:hover {
    background-color: #0077ed;
}

.small-button {
    background-color: var(--apple-blue);
    color: white;
    border: none;
    border-radius: 980px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 400;
    cursor: pointer;
}

.back-btn {
    background: none;
    border: none;
    color: var(--apple-blue);
    font-size: 17px;
    cursor: pointer;
    margin-top: 2rem;
    display: block;
}

.text-button {
    background: none;
    border: none;
    color: var(--apple-blue);
    font-size: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-weight: 500;
}

.toggle-icon {
    display: inline-block;
    margin-right: 5px;
    font-size: 18px;
    transition: transform 0.3s;
}

.toggle-icon.open {
    transform: rotate(45deg);
}

h2 {
    font-size: 32px;
    font-weight: 500;
    margin-bottom: 1.5rem;
    text-align: center;
}

h3 {
    font-size: 24px;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.instruction {
    font-size: 17px;
    color: var(--apple-dark-gray);
    margin-bottom: 1.5rem;
    text-align: center;
}

/* Form elements */
.options-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 15px;
    color: #1d1d1f;
}

.apple-select {
    appearance: none;
    background-color: white;
    border: 1px solid var(--apple-border);
    border-radius: 8px;
    padding: 10px 30px 10px 15px;
    font-size: 15px;
    width: 200px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2386868b' d='M0 0l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
}

.apple-input {
    border: 1px solid var(--apple-border);
    border-radius: 8px;
    padding: 10px 15px;
    font-size: 15px;
    width: 100px;
    margin-right: 1rem;
    margin-bottom: 0.5rem;
}

.apple-input.full-width {
    width: 100%;
    margin-right: 0;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-switch label {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--toggle-bg);
    border-radius: 34px;
    transition: .4s;
}

.toggle-switch label:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    border-radius: 50%;
    transition: .4s;
}

.toggle-switch input:checked + label {
    background-color: var(--toggle-active);
}

.toggle-switch input:checked + label:before {
    transform: translateX(18px);
}

.advanced-options {
    background-color: var(--apple-light-gray);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.small-textarea {
    width: 100%;
    min-height: 80px;
    border: 1px solid var(--apple-border);
    border-radius: 8px;
    padding: 12px;
    font-family: inherit;
    font-size: 15px;
    resize: vertical;
}

/* Tabs */
.content-input-container {
    margin-bottom: 1.5rem;
}

.input-tabs {
    display: flex;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--apple-border);
}

.tab-btn {
    background: none;
    border: none;
    padding: 10px 20px;
    font-size: 16px;
    color: var(--apple-dark-gray);
    cursor: pointer;
    position: relative;
}

.tab-btn.active {
    color: var(--apple-blue);
    font-weight: 500;
}

.tab-btn.active:after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--apple-blue);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.file-instructions {
    background-color: var(--apple-light-gray);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.file-instructions p {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.file-instructions ol {
    padding-left: 1.5rem;
    color: var(--apple-dark-gray);
}

.file-instructions li {
    margin-bottom: 0.5rem;
}

.file-note {
    background-color: rgba(255, 149, 0, 0.1);
    border-left: 3px solid var(--apple-orange);
    padding: 0.75rem;
    margin-top: 1rem;
    border-radius: 0 6px 6px 0;
    display: flex;
    align-items: center;
    font-size: 14px;
    color: #1d1d1f;
}

.file-note .icon {
    color: var(--apple-orange);
    font-size: 16px;
    margin-right: 0.5rem;
}

.file-details {
    background-color: var(--apple-light-gray);
    border-radius: 12px;
    padding: 1rem;
    margin-top: 1rem;
}

textarea {
    width: 100%;
    min-height: 200px;
    border: 1px solid var(--apple-border);
    border-radius: 12px;
    padding: 16px;
    font-family: inherit;
    font-size: 16px;
    margin-bottom: 1.5rem;
    resize: vertical;
}

#prompt-output {
    background-color: var(--apple-light-gray);
}

#generate-prompt-btn, #load-cards-submit-btn {
    display: block;
    margin: 0 auto;
}

.prompt-box {
    position: relative;
    margin-bottom: 2rem;
}

.prompt-box button {
    position: absolute;
    top: 16px;
    right: 16px;
}

.hidden {
    display: none;
}

.file-upload {
    margin-bottom: 1.5rem;
    display: flex;
    justify-content: center;
}

.file-upload input {
    display: none;
}

/* Flashcard styles */
.flashcard {
    width: 100%;
    max-width: 500px;
    height: 300px;
    margin: 0 auto;
    position: relative;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    box-shadow: 0 4px 15px var(--card-shadow);
    border-radius: 12px;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    padding: 20px;
    background-color: var(--card-background);
    border: 1px solid var(--card-border);
    color: var(--card-content-color);
}

.flashcard-back {
    transform: rotateY(180deg);
}

.card-content {
    padding: 15px;
    overflow-y: auto;
    max-height: 250px;
    color: var(--card-content-color);
    white-space: pre-wrap;
}

.stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1rem;
    color: var(--apple-dark-gray);
}

.progress-wrap {
    margin: 8px 0 16px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background: linear-gradient(180deg, #e9e9ec, #dcdce1);
    border-radius: 999px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(180deg, #0a84ff, #0077ed);
    transition: width 300ms ease;
}

.progress-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 13px;
    color: var(--apple-dark-gray);
}

.badge-group { display: flex; gap: 6px; }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--section-bg);
    border: 1px solid var(--apple-border);
    font-size: 12px;
}
.badge.correct {
    color: var(--correct-color);
    background: rgba(52, 199, 89, 0.15);
    border-color: rgba(52, 199, 89, 0.35);
}
.badge.incorrect {
    color: var(--incorrect-color);
    background: rgba(255, 59, 48, 0.15);
    border-color: rgba(255, 59, 48, 0.35);
}

/* Study controls enhancements */
.study-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    margin: 10px 0 20px;
    color: var(--apple-dark-gray);
    font-size: 14px;
}

.icon-btn {
    background: none;
    border: 1px solid var(--apple-border);
    border-radius: 999px;
    padding: 8px 12px;
    cursor: pointer;
}

.hint-box {
    margin: 8px auto 16px;
    max-width: 500px;
    background: var(--section-bg);
    border: 1px solid var(--apple-border);
    border-radius: 10px;
    padding: 10px 12px;
    color: var(--text-color);
}

.card-controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.answer-buttons {
    display: flex;
    gap: 1rem;
}

.answer-btn {
    padding: 8px 20px;
    border-radius: 980px;
    border: none;
    font-size: 16px;
    cursor: pointer;
    color: white;
}

.incorrect {
    background-color: var(--apple-red);
}

.correct {
    background-color: var(--apple-green);
}

.navigation-buttons {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 400px;
}

.nav-btn {
    background: none;
    border: none;
    color: var(--apple-blue);
    font-size: 16px;
    cursor: pointer;
}

.study-options {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    margin-top: 2rem;
}
.shared-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.shared-owner-name {
    font-weight: 600;
}

.shared-set-title {
    color: var(--apple-dark-gray);
}

footer {
    margin-top: 4rem;
    text-align: center;
    color: var(--apple-dark-gray);
    font-size: 14px;
}

footer a {
    color: var(--apple-blue);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Library Section Styles */
.library-section {
    margin-top: 30px;
    background-color: var(--section-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 5px var(--card-shadow);
}

.library-section h2 {
    font-size: 20px;
    margin-bottom: 15px;
    font-weight: 600;
}

.storage-note {
    font-size: 12px;
    color: var(--note-color);
    margin-bottom: 15px;
    font-style: italic;
}

.library-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.empty-library-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 20px;
    color: var(--note-color);
    font-style: italic;
}

.library-item {
    background-color: var(--library-item-bg);
    border: 1px solid var(--library-item-border);
    border-radius: 8px;
    padding: 15px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.library-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px var(--card-shadow);
}

.library-item-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 8px;
}

.library-item-description {
    font-size: 14px;
    color: var(--note-color);
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.library-item-stats {
    font-size: 12px;
    display: flex;
    justify-content: space-between;
}

.library-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 12px;
}

.library-action-btn {
    background: none;
    border: none;
    font-size: 12px;
    color: var(--primary-color);
    cursor: pointer;
}

.library-action-btn:hover {
    text-decoration: underline;
}

.library-action-btn.delete {
    color: var(--incorrect-color);
}

/* Modal Dialog Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: var(--background-color);
    border-radius: 12px;
    padding: 25px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons.code-buttons {
    flex-wrap: wrap;
    justify-content: space-between;
}

.modal-buttons.code-buttons .apple-button {
    flex: 1 1 calc(50% - 5px);
}

@media (max-width: 420px) {
    .modal-buttons.code-buttons .apple-button {
        flex: 1 1 100%;
    }
}

.apple-button.secondary {
    background-color: var(--secondary-button-bg);
    color: var(--text-color);
}

.apple-button.secondary:hover {
    background-color: var(--secondary-button-hover);
}