:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, "Noto Sans TC", "PingFang TC", sans-serif;
  background: #f3f6fa;
  color: #18243b;
  --muted: #52637b;
  --border: #dce4ef;
  --primary: #214eaa;
  --primary-dark: #183d89;
  --surface: #fff;
  --shadow: 0 12px 32px #18243b08;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; line-height: 1.55; }
button, input { font: inherit; }
a { color: inherit; }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 3px solid #2761c7;
  outline-offset: 3px;
}

.topbar { border-bottom: 1px solid var(--border); background: var(--surface); }
.topbar-content, .shell { width: min(100% - 3rem, 76rem); margin-inline: auto; }
.topbar-content { display: flex; align-items: center; justify-content: space-between; min-height: 4.5rem; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: .7rem; font-weight: 750; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 2.2rem; height: 2.2rem; border-radius: .6rem; color: #fff; background: var(--primary); }
.nav-link { font-size: .875rem; font-weight: 650; color: var(--primary); text-decoration: none; }
.nav-link:hover { text-decoration: underline; }
.shell { padding-block: 2.5rem 4rem; }
.page-heading { margin-bottom: 1.65rem; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.75rem, 3.4vw, 2.35rem); line-height: 1.25; letter-spacing: -.025em; }
h2 { font-size: 1.08rem; line-height: 1.4; }
.page-heading p, .gate p, .admin-panel > p { margin-top: .55rem; color: var(--muted); }
.panel { border: 1px solid var(--border); border-radius: .9rem; background: var(--surface); box-shadow: var(--shadow); }
.gate { max-width: 36rem; margin: clamp(1rem, 9vh, 6rem) auto 0; padding: 3rem 1.5rem; text-align: center; }
.gate h1 { margin-top: 1.3rem; font-size: 1.6rem; }
.gate .button { margin-top: 1rem; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .55rem .9rem;
  border: 1px solid transparent;
  border-radius: .55rem;
  font-size: .9rem;
  font-weight: 650;
  line-height: 1.3;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.button:disabled { opacity: .6; cursor: wait; }
.primary { color: #fff; background: var(--primary); }
.primary:hover:not(:disabled) { background: var(--primary-dark); }
.secondary { border-color: var(--border); color: var(--primary-dark); background: var(--surface); }
.secondary:hover:not(:disabled) { background: #edf3ff; }

.library-grid { display: grid; grid-template-columns: minmax(17.5rem, 22rem) minmax(0, 1fr); align-items: start; gap: 1rem; }
.drawings, .preview { min-width: 0; }
.list-heading { padding: 1.15rem 1rem .85rem; }
.search-form { display: flex; gap: .45rem; margin-top: .65rem; }
.search-field { position: relative; flex: 1; min-width: 0; }
.search-symbol { position: absolute; top: 1rem; left: .75rem; width: .75rem; height: .75rem; border: 1.5px solid var(--muted); border-radius: 50%; pointer-events: none; }
.search-symbol::after { content: ''; position: absolute; width: .36rem; height: 1.5px; transform: rotate(45deg); top: .57rem; left: .49rem; background: var(--muted); }
input[type="search"], input[type="text"], input[type="url"], input[type="file"] {
  width: 100%;
  min-height: 2.75rem;
  padding: .55rem .7rem;
  border: 1px solid #cbd7e7;
  border-radius: .55rem;
  color: inherit;
  background: #fff;
}
input[type="search"] { padding-left: 2.05rem; }
input::placeholder { color: #61728b; opacity: 1; }
.list-status { padding: 0 1rem .75rem; color: var(--muted); font-size: .875rem; }
.results { margin: 0; padding: 0; list-style: none; }
.drawing-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: .5rem;
  align-items: center;
  width: 100%;
  padding: .8rem 1rem;
  border: 0;
  border-top: 1px solid var(--border);
  text-align: left;
  color: inherit;
  background: transparent;
  cursor: pointer;
}
.drawing-row strong { overflow-wrap: anywhere; font-size: .95rem; }
.drawing-row > span:nth-child(2) { grid-row: 2; color: var(--muted); font-size: .875rem; }
.drawing-row .file-type { grid-area: 1 / 2 / 3 / 3; padding: .12rem .4rem; border-radius: .25rem; color: #234878; background: #e9f0fa; font-size: .75rem; font-weight: 750; }
.drawing-row:hover, .drawing-row[aria-pressed="true"] { background: #edf3ff; }
.drawing-row[aria-pressed="true"] { box-shadow: inset 3px 0 var(--primary); }
.drawing-row:focus-visible { outline-offset: -3px; }
.results > li:last-child .drawing-row { border-radius: 0 0 .85rem .85rem; }
.more { margin: .85rem 1rem; }

.preview { overflow: hidden; }
.preview-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; min-height: 4rem; padding: .85rem 1rem; border-bottom: 1px solid var(--border); }
.preview-heading > div { min-width: 0; overflow-wrap: anywhere; }
.preview-heading p { color: var(--muted); font-size: .875rem; }
.preview-empty { display: grid; align-content: center; justify-items: center; gap: 1rem; min-height: min(55vh, 34rem); padding: 2rem 1rem; background: #f8fafd; color: var(--muted); text-align: center; }
.document-symbol { position: relative; width: 2.85rem; height: 3.3rem; margin-inline: auto; border: 2px solid #7894bd; border-radius: .45rem; background: #eaf1fb; }
.document-symbol::before, .document-symbol::after { content: ''; position: absolute; left: .55rem; top: 1.2rem; width: 1.55rem; height: .12rem; border-radius: 1rem; background: #7894bd; }
.document-symbol::after { top: 1.8rem; width: 1.15rem; }
.pdf-frame { display: block; width: 100%; height: max(32rem, 68vh); border: 0; background: #edf1f7; }

.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; align-items: start; }
.admin-panel { padding: 1.5rem; min-width: 0; }
.admin-panel h2 { font-size: 1.2rem; }
.admin-form, .form-field { display: grid; justify-items: start; }
.admin-form { gap: 1rem; margin-top: 1.25rem; }
.form-field { width: 100%; gap: .35rem; }
.form-field label { font-size: .9rem; font-weight: 650; }
.field-note { color: var(--muted); font-size: .875rem; }
input[type="file"]::file-selector-button { margin-right: .65rem; padding: .2rem .65rem; border: 1px solid var(--border); border-radius: .35rem; color: var(--primary-dark); background: #edf3ff; cursor: pointer; }
.share-actions { display: flex; flex-wrap: wrap; gap: .45rem; margin-top: .2rem; }
.form-status { width: 100%; padding: .6rem .75rem; border-radius: .45rem; background: #edf3ff; color: var(--primary-dark); font-size: .9rem; }
.form-status[data-type="success"] { background: #e8f7ed; color: #195f38; }
.form-status[data-type="error"] { background: #fff0ef; color: #8a2727; }

.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

@media (max-width: 760px) {
  .topbar-content, .shell { width: min(100% - 1.5rem, 76rem); }
  .topbar-content { min-height: 3.7rem; }
  .shell { padding-block: 1.6rem 2.5rem; }
  .library-grid, .admin-grid { grid-template-columns: minmax(0, 1fr); }
  .preview-empty { min-height: 15rem; }
  .pdf-frame { height: max(24rem, 65vh); }
  .admin-panel { padding: 1.15rem; }
}
