
/* Shared workspace layout */
:root { --radius: 12px; --radius-lg: 20px; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--accent-hover); outline-offset: 3px; }
.skip-link { position: fixed; top: .5rem; left: .5rem; z-index: 30; transform: translateY(-160%); }
.skip-link:focus { transform: none; }
.topbar { min-height: 64px; padding: .6rem max(1rem, calc((100vw - 1280px)/2)); }
.brand-mark { width: 36px; height: 36px; border-radius: 11px; }
.nav-right, .workspace-nav { display: flex; align-items: center; gap: .35rem; }
.nav-link { padding: .5rem .75rem; border-radius: 10px; white-space: nowrap; }
.nav-link[aria-current=page] { background: var(--accent); color: var(--accent-text); }
.nav-user { margin-inline: .6rem; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; }
.container { width: min(100%, 1100px); padding: clamp(1rem,4vw,3rem); margin: auto; }
.card, .login-box { border-radius: var(--radius-lg); }
.eyebrow { color: var(--accent-text); font-size: .76rem; font-weight: 700; letter-spacing: .14em; margin: 0 0 .5rem; }
.page-title { font-size: clamp(1.65rem, 4vw, 2.5rem); line-height: 1.2; margin: 0 0 .6rem; overflow-wrap: anywhere; }
.login-wrap { width: min(100%, 860px); max-width: none; margin: clamp(1rem,7vh,5rem) auto; display: grid; grid-template-columns: 1fr 1fr; align-items: stretch; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: 24px; overflow: hidden; }
.login-intro { background: var(--accent); color: var(--accent-text); padding: clamp(1.4rem,5vw,3.5rem); display: grid; align-content: center; }
.login-intro p:last-child { max-width: 24ch; }
.login-panel { padding: clamp(1.4rem,4vw,3rem); }
.login-panel .login-box { padding: 0; border: 0; box-shadow: none; }
.field-label { font-weight: 600; display: grid; gap: .35rem; }
.btn, .upload-label { min-height: 42px; }
.drive-container { width: min(100%, 1320px); margin: 0 auto; padding: clamp(1rem,3vw,2rem); gap: 1rem; height: auto; min-height: calc(100vh - 64px); }
.drive-sidebar, .drive-main { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--paper); min-width: 0; }
.drive-sidebar { align-self: start; }
.drive-main { padding: clamp(1rem,3vw,2rem); }
.drive-toolbar { gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.toolbar-folder-name { overflow-wrap: anywhere; font-size: clamp(1.35rem,3vw,2rem); }
.toolbar-actions { flex-wrap: wrap; }
.dropzone { background: var(--bg); border-radius: 14px; text-align: center; }
.dropzone:focus-within { outline: 3px solid var(--accent-hover); }
.file-grid { gap: .5rem; }
.file-row { border-radius: 12px; }
.file-card-actions, .folder-delete-btn { opacity: 1; }
.card-action-btn { min-width: 38px; min-height: 38px; }
.study { width: min(100%, 820px); margin: auto; }
.study-card { padding: clamp(1.2rem,6vw,3rem); text-align: center; background: var(--paper); border: 1px solid var(--line); border-radius: 24px; }
.study-prompt { font-size: clamp(1.55rem,4.5vw,2.8rem); line-height: 1.25; overflow-wrap: anywhere; min-height: 2.5em; margin: .75rem 0 1rem; }
.study-answer { font-size: 1.15rem; font-weight: 600; }

.study-actions {
  position: fixed;
  z-index: 10;
  inset: auto 0 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 330px));
  justify-content: center;
  gap: .6rem;
  padding: .65rem 1rem calc(.65rem + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgb(26 26 26 / .07);
}
.study-actions .btn { min-height: 48px; }
#study-meaning, #study-english { scroll-margin-bottom: calc(84px + env(safe-area-inset-bottom)); }
.preview-header { margin-bottom: 1.25rem; }
.preview-header > a:first-child { display: inline-block; margin-bottom: 1rem; }
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; position: static; }
  .nav-user { display: none; }
  .nav-link { padding-inline: .55rem; }
  .login-wrap { grid-template-columns: 1fr; }
  .drive-container { display: grid; grid-template-columns: minmax(0,1fr); min-height: 0; }
  .drive-sidebar { width: auto; max-height: 38vh; overflow: auto; }
  .drive-main { width: auto; }
  .file-row { flex-wrap: wrap; }
}

.study-nav { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.5rem; }
.study-nav a { color: var(--ink); font-weight: 600; }
.study-nav span { color: var(--muted); font-size: .75rem; letter-spacing: .13em; }
.study-hero { padding: clamp(1.4rem,5vw,3rem); background: var(--accent); color: var(--accent-text); border-radius: 24px; }
.study-hero h1 { font-size: clamp(2rem,6vw,3.5rem); }
.study-hero p:last-child { margin-bottom: 0; }
.study-step { margin-top: 1.75rem; }
.study-step h2 { font-size: 1.12rem; margin: 0 0 .75rem; }
.study-step h2 span { color: var(--accent-text); margin-right: .35rem; font-size: .8rem; }
.study-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; }
.study-choice { display: grid; justify-items: start; align-content: start; gap: .35rem; width: 100%; padding: clamp(.85rem,3vw,1.45rem); text-align: left; color: var(--ink); background: var(--paper); border: 1px solid var(--line); border-radius: 16px; font: inherit; cursor: pointer; }
.study-choice:hover:not(:disabled), .study-choice[aria-pressed="true"] { border-color: var(--accent-hover); box-shadow: inset 0 0 0 1px var(--accent-hover); }
.study-choice[aria-pressed="true"] { background: color-mix(in srgb, var(--accent) 18%, var(--paper)); }
.study-choice span { color: var(--muted); font-size: .85rem; }
.study-track strong { font-size: clamp(1.55rem,5vw,2.4rem); line-height: 1; }
.study-choice .study-tag { color: var(--accent-text); font-size: .68rem; font-weight: 700; letter-spacing: .1em; }
.study-choice:disabled { background: var(--bg); border-style: dashed; color: var(--muted); cursor: default; }
#study-session { max-width: 680px; margin: auto; }
.study-context { border-top: 1px solid var(--line); padding-top: .75rem; }
.study-context p { margin: .3rem 0; }
.study-context p:last-child { color: var(--muted); }

.login-remember { display: flex; align-items: center; gap: .5rem; min-height: 42px; }
.login-remember input { width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--accent); }

.drive-path { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem; margin-bottom: .85rem; font-size: .9rem; }
.drive-path > :not(:first-child)::before { content: "›"; margin-right: .45rem; color: var(--muted); }
.drive-path a, .drive-main .file-name { color: var(--ink); }
.drive-search { margin-bottom: 1rem; }
.drive-search input, #drive-move-target { min-height: 44px; width: 100%; padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font: inherit; }
#drive-status { white-space: pre-line; overflow-wrap: anywhere; }
#drive-move { width: min(92vw, 440px); padding: 1.5rem; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); color: var(--ink); }
#drive-move::backdrop { background: rgb(26 26 26 / .45); }
.drive-trash { border-top: 1px solid var(--line); margin-top: 1.25rem; padding-top: .75rem; }
.drive-trash summary { cursor: pointer; padding: .4rem 0; font-weight: 600; }
.drive-trash ul { list-style: none; padding: 0; }
.drive-trash li { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding-block: .3rem; overflow-wrap: anywhere; }

#drive-folders-title, #drive-files-title { font-size: 1rem; margin: 1.25rem 0 .65rem; }
#drive-folder-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 175px), 1fr)); gap: .65rem; margin: 0; padding: 0; list-style: none; }
#drive-folder-cards a { display: grid; align-content: center; gap: .3rem; min-height: 72px; padding: .75rem; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; overflow-wrap: anywhere; }
#drive-folder-cards a:hover { border-color: var(--accent-hover); background: var(--bg); }
#drive-folder-cards span { color: var(--muted); font-size: .8rem; }

.drive-tools { display: flex; align-items: end; flex-wrap: wrap; gap: .65rem; margin-bottom: 1rem; }
.drive-tools .drive-search { flex: 1 1 12rem; margin: 0; }
.drive-upload-limit { color: var(--muted); font-size: .75rem; }
#drive-search-context { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem; }
.drive-main dialog { width: min(92vw, 460px); max-height: 85vh; padding: 1.35rem; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); background: var(--paper); }
.drive-main dialog::backdrop { background: rgb(26 26 26 / .45); }
#drive-trash-list { padding: 0; list-style: none; }
#drive-trash-list li { display: flex; justify-content: space-between; align-items: center; gap: .6rem; padding: .5rem 0; overflow-wrap: anywhere; }
#drive-folder-cards li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: .2rem; border: 1px solid var(--line); border-radius: 12px; }
#drive-folder-cards a { border: 0; }
.drive-actions { position: relative; margin-inline-end: .25rem; }
.drive-actions summary { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; list-style: none; border-radius: 8px; font-size: 1.35rem; }
.drive-actions summary::-webkit-details-marker { display: none; }
.drive-actions summary:hover, .drive-actions[open] summary { background: var(--bg); }
.drive-actions > div { position: absolute; z-index: 3; inset-inline-end: 0; width: max-content; padding: .3rem; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 6px 18px rgb(0 0 0 / .12); }
.drive-actions button { display: block; width: 100%; min-height: 44px; padding: .4rem .7rem; text-align: left; background: transparent; color: var(--ink); font: inherit; border: 0; border-radius: 6px; cursor: pointer; }
.drive-actions button:hover { background: var(--bg); }
.drive-actions button:disabled { opacity: .55; cursor: default; }
.drive-main .file-name { display: flex; align-items: center; gap: .55rem; min-height: 44px; white-space: normal; overflow-wrap: anywhere; text-decoration: underline; text-underline-offset: .18em; }
.drive-main .file-row { flex-wrap: nowrap; }
.drive-main .file-info { min-width: 0; }
.drive-main .dropzone { display: none; }
.drive-main .dropzone.is-visible { display: grid; place-items: center; position: fixed; z-index: 5; inset-inline: max(1rem, calc((100vw - 680px) / 2)); bottom: 1rem; border-color: var(--accent-hover); background: var(--paper); box-shadow: 0 6px 20px rgb(0 0 0 / .12); }
.study-choice { text-decoration: none; }
@media (max-width: 760px) {
  .drive-sidebar { display: none; }
  .drive-toolbar .toolbar-actions { justify-content: flex-start; }
}

@media (max-width: 600px), (max-height: 700px) {
  .study-card { padding: .85rem; }
  .study-prompt { min-height: 0; margin: .2rem 0 .55rem; }
  .study-answer { margin: .45rem 0; }
  .study-actions { gap: .35rem; padding-inline: .55rem; }
  .study-actions .btn { padding-inline: .25rem; white-space: nowrap; }
}

.study:has(#study-session:not([hidden])) .study-nav { display: none; }
.container:has(#study-session:not([hidden])) { padding-top: .65rem; }
.study-session-bar { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; gap: .45rem; margin-bottom: .6rem; }
.study-session-meta { display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: .2rem .55rem; text-align: center; }
.study-session-meta h1, #study-progress { margin: 0; font-size: .9rem; }
#study-progress { color: var(--muted); }
#study-options { position: relative; z-index: 3; }
#study-options summary { display: grid; place-items: center; width: 44px; height: 44px; cursor: pointer; list-style: none; border-radius: 8px; font-size: 1.25rem; }
#study-options summary::-webkit-details-marker { display: none; }
#study-options[open] summary { background: var(--bg); }
.study-options-panel { position: absolute; inset-inline-end: 0; top: calc(100% + .25rem); width: min(12rem, calc(100vw - 2rem)); padding: .25rem; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 6px 18px rgb(0 0 0 / .12); }
#study-reset { display: block; width: 100%; min-height: 44px; padding: .5rem .65rem; border: 0; border-radius: 8px; background: transparent; color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
#study-reset:hover, #study-reset:focus-visible { background: var(--bg); }
.study-assistive { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.study-prompt { min-height: 0; margin: .15rem 0 .45rem; }
.container:has(#study-session:not([hidden])) { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
#study-session { display: flex; flex-direction: column; min-height: calc(100dvh - 70px - .65rem - env(safe-area-inset-bottom)); }
.study-card { flex: 1; display: flex; flex-direction: column; padding: .85rem .85rem 0; }
.study-answer-area { flex: 1; display: grid; min-height: 80px; }
.study-answer-area > * { grid-area: 1 / 1; min-width: 0; }
#study-reveal { width: 100%; min-height: 100%; border: 0; border-radius: 12px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
#study-reveal[aria-expanded="true"] { color: transparent; }
#study-meaning { z-index: 1; align-self: start; padding: .55rem 0 1rem; pointer-events: none; overflow-wrap: anywhere; }

#drive-trash-list li { display: grid; gap: .35rem; }
.drive-trash-actions { display: flex; flex-wrap: wrap; gap: .35rem; }
.drive-trash-actions .btn { min-height: 44px; white-space: nowrap; }
.drive-trash-actions .btn:last-child { color: #991b1b; }
.drive-main .file-row, .drive-main { overflow: visible; }
.drive-main .file-row:has(.drive-actions[open]), #drive-folder-cards li:has(.drive-actions[open]) { position: relative; z-index: 4; }
.drive-actions > div { max-width: calc(100vw - 2rem); }
.drive-toolbar .toolbar-actions { flex-wrap: wrap; }

/* Keep file controls beside the file name, with one viewport-bound menu. */
.drive-main .file-grid { grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr)); padding: 0; }
.drive-main .file-row { display: flex; flex-direction: row; align-items: center; gap: .4rem; padding: .65rem; overflow: visible; }
.drive-main .file-info { flex: 1; width: auto; text-align: left; }
.drive-main .file-name { display: flex; min-width: 0; line-height: 1.4; }
.drive-main .file-icon { flex: 0 0 52px; width: 52px; height: 52px; font-size: 1.7rem; }
.drive-main .file-meta-text { padding-left: calc(52px + .55rem); }
.drive-main .file-card-actions { position: static; flex: 0 0 auto; opacity: 1; }
.drive-actions { margin: 0; }
.drive-actions summary { user-select: none; }
.drive-actions > div { position: fixed; z-index: 50; inset: auto; max-width: calc(100vw - 16px); box-shadow: 0 8px 24px rgb(0 0 0 / .18); }
.drive-actions button { padding-inline: .85rem; }
#drive-rename-input { width: 100%; min-height: 44px; padding: .5rem .75rem; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: var(--paper); font: inherit; }
.drive-dialog-actions { display: flex; justify-content: flex-end; gap: .5rem; }
