:root {
  --ink: #151b21;
  --muted: #65717c;
  --line: #d8e0e5;
  --soft: #f3f5f6;
  --paper: #fff;
  --navy: #081b2d;
  --red: #d9213d;
  --green: #18794e;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--soft); font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif; line-height: 1.5; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.login-screen { display: grid; min-height: 100vh; place-items: center; padding: 24px; background: var(--navy); }
.login-panel { width: min(430px, 100%); padding: 38px; border-top: 4px solid var(--red); border-radius: 8px; background: #fff; }
.login-panel img { width: 54px; height: 54px; object-fit: contain; }
.login-panel > p { margin: 22px 0 5px; color: var(--red); font-size: .72rem; font-weight: 900; letter-spacing: .1em; }
.login-panel h1 { margin: 0 0 28px; font-size: 2rem; }
.login-panel label { display: grid; gap: 7px; font-size: .86rem; font-weight: 800; }
.login-panel input { height: 46px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px; }
.login-panel button { width: 100%; min-height: 46px; margin-top: 16px; color: #fff; border: 0; border-radius: 6px; background: var(--red); font-weight: 900; }
.login-panel > a { display: block; margin-top: 22px; color: var(--muted); text-align: center; font-size: .82rem; }

.admin-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; min-height: 68px; padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.97); }
.admin-header > div { display: flex; gap: 8px; }
.admin-brand { display: flex; align-items: center; gap: 10px; }
.admin-brand img { width: 40px; height: 40px; object-fit: contain; }
.admin-brand span { display: grid; line-height: 1.1; }
.admin-brand small { color: var(--muted); font-size: .58rem; letter-spacing: .08em; }

.admin-layout { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 68px); }
.admin-sidebar { padding: 28px 18px; color: #fff; background: var(--navy); }
.admin-sidebar > p { margin: 0 10px 12px; color: rgba(255,255,255,.5); font-size: .7rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.admin-sidebar > button { width: 100%; min-height: 44px; margin-bottom: 5px; padding: 0 12px; color: rgba(255,255,255,.76); text-align: left; border: 1px solid transparent; border-radius: 6px; background: transparent; font-weight: 800; }
.admin-sidebar > button.is-active { color: #fff; border-color: rgba(255,255,255,.16); background: rgba(255,255,255,.1); }
.sidebar-note { display: grid; gap: 8px; margin-top: 34px; padding: 16px 12px; border-top: 1px solid rgba(255,255,255,.15); color: rgba(255,255,255,.6); font-size: .76rem; }
.sidebar-note strong { color: #fff; }

.admin-main { min-width: 0; padding: 36px; }
.admin-view { display: none; width: min(1180px, 100%); margin: 0 auto; }
.admin-view.is-active { display: block; }
.view-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.view-heading p, .editor-heading p { margin: 0 0 4px; color: var(--red); font-size: .7rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; }
.view-heading h2 { margin: 0; font-size: 2rem; }
.view-heading > span { color: var(--muted); font-size: .82rem; }

.content-form, .editor-panel, .content-table { border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.form-section { padding: 26px; border-bottom: 1px solid var(--line); }
.form-section:last-of-type { border-bottom: 0; }
.form-section h3 { margin: 0 0 18px; font-size: 1.1rem; }
.section-help { margin: -8px 0 18px; color: var(--muted); font-size: .8rem; }

.language-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.language-block { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfc; }
.language-block h4 { margin: 0 0 14px; color: var(--navy); font-size: .86rem; }
.language-block label, .content-form > label, .editor-panel > label, .field-grid label, .image-field > label:first-child { display: grid; gap: 6px; margin-bottom: 12px; color: #35414c; font-size: .78rem; font-weight: 800; }
.language-block label:last-child { margin-bottom: 0; }

input, textarea, select { width: 100%; color: var(--ink); border: 1px solid #cbd5dc; border-radius: 5px; background: #fff; outline: none; }
input, select { height: 42px; padding: 0 10px; }
textarea { min-height: 94px; padding: 10px; resize: vertical; line-height: 1.55; }
textarea.long { min-height: 150px; }
input:focus, textarea:focus, select:focus { border-color: #3e6e96; box-shadow: 0 0 0 3px rgba(62,110,150,.12); }

.field-grid { display: grid; gap: 12px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.checkbox-label { display: flex !important; align-items: center; gap: 9px !important; min-height: 42px; margin-top: 20px; }
.checkbox-label input { width: 18px; height: 18px; }

.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; min-height: 76px; padding: 15px 22px; border-top: 1px solid var(--line); background: #f8fafb; }
.form-message { margin-right: auto; color: var(--muted); font-size: .8rem; }
.form-message.is-error { color: #b42318; }
.form-message.is-success { color: var(--green); }
.primary-button, .quiet-button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 0 15px; border-radius: 6px; font-weight: 850; }
.primary-button { color: #fff; border: 1px solid var(--red); background: var(--red); }
.quiet-button { color: var(--ink); border: 1px solid var(--line); background: #fff; }

.content-table { overflow: hidden; }
.table-row { display: grid; grid-template-columns: minmax(220px, 1.4fr) minmax(130px, .55fr) minmax(100px, .45fr) auto; gap: 16px; align-items: center; min-height: 74px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.table-row:last-child { border-bottom: 0; }
.table-row.is-head { min-height: 44px; color: var(--muted); background: #f7f9fa; font-size: .72rem; font-weight: 900; text-transform: uppercase; }
.table-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.table-title img { width: 54px; height: 46px; flex: 0 0 auto; object-fit: cover; border-radius: 4px; background: var(--soft); }
.table-title strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table-title small { color: var(--muted); }
.status { display: inline-flex; width: fit-content; padding: 4px 8px; border-radius: 5px; font-size: .72rem; font-weight: 900; }
.status.published { color: #0c6843; background: #e7f6ef; }
.status.draft { color: #715400; background: #fff5ce; }
.row-actions { display: flex; gap: 6px; }
.row-actions button { min-height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 5px; background: #fff; font-size: .78rem; font-weight: 800; }
.row-actions button.danger { color: #b42318; }
.table-empty { padding: 44px; color: var(--muted); text-align: center; }

.editor-panel { margin-top: 22px; padding: 24px; }
.editor-heading { display: flex; justify-content: space-between; margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.editor-heading h3 { margin: 0; font-size: 1.35rem; }
.icon-close { width: 38px; height: 38px; color: var(--muted); border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 1.3rem; }
.editor-panel > label { margin: 12px 0; }
.editor-panel .language-fields { margin-top: 20px; }
.editor-panel .form-actions { margin: 24px -24px -24px; }

.image-field { display: grid; grid-template-columns: minmax(260px, 1fr) auto 110px; gap: 12px; align-items: end; margin: 12px 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfc; }
.image-field > label:first-child { margin: 0; }
.upload-button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 0 14px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: .78rem; font-weight: 850; cursor: pointer; }
.upload-button input { display: none; }
.image-field img { width: 110px; height: 72px; object-fit: cover; border: 1px solid var(--line); border-radius: 5px; background: var(--soft); }

.video-admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.video-admin-item { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: #fbfcfc; }
.video-admin-item .editor-heading { align-items: start; margin-bottom: 14px; }
.video-admin-item .editor-heading h4 { margin: 0; font-size: 1rem; }
.video-admin-item .editor-heading .checkbox-label { margin: 0; }
.video-admin-item > label:not(.upload-button) { display: grid; gap: 6px; margin-bottom: 12px; color: #35414c; font-size: .78rem; font-weight: 800; }
.video-admin-item > .upload-button { width: 100%; margin-bottom: 10px; }
.video-admin-item video { display: block; width: 100%; aspect-ratio: 16 / 9; margin-bottom: 14px; object-fit: contain; border-radius: 5px; background: #07111a; }
.video-admin-item .language-fields { grid-template-columns: 1fr; }

@media (max-width: 980px) {
  .admin-layout { grid-template-columns: 1fr; }
  .admin-sidebar { display: flex; gap: 7px; overflow-x: auto; padding: 12px 18px; }
  .admin-sidebar > p, .sidebar-note { display: none; }
  .admin-sidebar > button { width: auto; min-width: 110px; margin: 0; text-align: center; }
  .language-fields { grid-template-columns: 1fr; }
  .video-admin-grid { grid-template-columns: 1fr; }
  .admin-main { padding: 24px; }
}

@media (max-width: 680px) {
  .admin-header { padding: 0 14px; }
  .admin-brand small { display: none; }
  .admin-main { padding: 18px 12px; }
  .view-heading { align-items: flex-start; }
  .view-heading > span { display: none; }
  .view-heading h2 { font-size: 1.6rem; }
  .field-grid.two, .field-grid.three { grid-template-columns: 1fr; }
  .table-row { grid-template-columns: 1fr auto; gap: 8px; }
  .table-row.is-head { display: none; }
  .table-row > :nth-child(2), .table-row > :nth-child(3) { grid-column: 1; }
  .row-actions { grid-column: 2; grid-row: 1 / span 3; flex-direction: column; }
  .image-field { grid-template-columns: 1fr; }
  .image-field img { width: 100%; height: 150px; }
  .form-actions { flex-wrap: wrap; }
  .form-message { width: 100%; }
}
