:root {
  --ink: #19221f;
  --muted: #6f7874;
  --paper: #f4f3ed;
  --card: #fbfbf8;
  --line: #dedfd8;
  --accent: #df5b38;
  --accent-dark: #bd4125;
  --green: #214a40;
  --lime: #c9d765;
  --shadow: 0 18px 55px rgba(36, 47, 42, .08);
  --fs-xs: 11.5px;
  --fs-sm: 13px;
  --fs-base: 14.5px;
  --fs-md: 16px;
  --fs-lg: 20px;
  --fs-xl: 24px;
  font-family: "DM Sans", "Noto Sans TC", sans-serif;
  color: var(--ink);
  background: var(--paper)
}

* {
  box-sizing: border-box
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
}

body.sidebar-locked,
body.modal-open {
  overflow: hidden !important;
  touch-action: none;
}

button,
select,
textarea,
input,
a {
  font: inherit;
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

/* KaTeX & Code block overflow protection */
.katex-display {
  overflow-x: auto !important;
  overflow-y: hidden !important;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  padding: 6px 0;
  margin: 0.8em 0;
}

.katex {
  max-width: 100%;
}

pre, code {
  max-width: 100%;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .035;
  z-index: 10;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E")
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 20, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 24;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 240px;
  background: #1f3e36;
  color: #fff;
  padding: 26px 16px 20px;
  display: flex;
  flex-direction: column;
  z-index: 25;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: .07em;
  padding: 0 8px 30px;
}

.brand small {
  display: block;
  color: #aabdb6;
  font-size: 8px;
  letter-spacing: .22em;
  margin-top: 1px
}

.brand-mark {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: flex-end;
  gap: 2.5px;
  padding: 5px;
  background: var(--lime);
  border-radius: 4px;
  transform: rotate(-3deg)
}

.brand-mark span {
  display: block;
  width: 4px;
  background: #203f37;
  border-radius: 4px
}

.brand-mark span:nth-child(1) {
  height: 12px
}

.brand-mark span:nth-child(2) {
  height: 19px
}

.brand-mark span:nth-child(3) {
  height: 15px
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  border: 0;
  background: transparent;
  color: #aec0ba;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  border-radius: 8px;
  padding: 7px 11px;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 500;
  transition: .2s;
  white-space: nowrap;
}

.nav-item > span:not(.icon):not(.nav-count) {
  white-space: nowrap;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, .09);
  color: #fff
}

.nav-item.active {
  box-shadow: inset 3px 0 var(--lime)
}

.nav-item .icon {
  width: 19px;
  text-align: center;
  font-size: 16px;
}

.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  line-height: 1.4;
  min-width: 18px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(222, 91, 55, 0.4);
  transition: all 0.2s ease;
  letter-spacing: 0;
}

.nav-item.active .nav-badge {
  background: var(--lime);
  color: #172722;
  box-shadow: 0 1px 4px rgba(201, 215, 101, 0.4);
}

.nav-badge.hidden {
  display: none !important;
}

.nav-count {
  display: none !important;
}

.sidebar-spacer {
  flex: 1
}

.plan-card {
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(0, 0, 0, .24);
  border-radius: 9px;
  padding: 12px;
  margin-top: 6px;
  margin-bottom: 14px;
}

.plan-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: #ffffff;
}

.plan-head b {
  font-size: 10px;
  color: #a3e635;
  background: rgba(163, 230, 53, 0.12);
  border: 1px solid rgba(163, 230, 53, 0.35);
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
}

.usage-bar {
  height: 5px;
  background: rgba(255, 255, 255, 0.15);
  margin: 10px 0 8px;
  border-radius: 3px;
}

.usage-bar i {
  display: block;
  width: 20%;
  height: 100%;
  background: linear-gradient(90deg, #34d399, #10b981);
  border-radius: 3px;
}

.plan-card p {
  margin: 0;
  font-size: 11px;
  color: #d1fae5;
}

.plan-card strong {
  color: #34d399;
}

.profile {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, .1);
  padding: 18px 5px 0;
  background: none;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #d6a16d;
  color: #fff;
  font-size: 12px
}

.profile>span:nth-child(2) {
  font-size: 12px;
  font-weight: 600
}

.profile small {
  display: block;
  font-size: 8px;
  color: #8fa49d;
  font-weight: 400
}

.more {
  margin-left: auto;
  color: #8fa49d;
  font-size: 10px
}

main {
  margin-left: 240px;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: calc(68px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: env(safe-area-inset-top, 0px) 42px 0;
  background: rgba(244, 243, 237, .86);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 15;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, height 0.25s ease;
}

.topbar.collapsed {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
  height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.btn-topbar-collapse {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 2px;
  flex-shrink: 0;
}

.btn-topbar-collapse:hover {
  background: #f0f4ef;
  color: var(--green);
  border-color: var(--green);
  transform: translateY(-1px);
}

.btn-topbar-restore {
  position: fixed;
  top: 21px;
  right: 42px;
  z-index: 20;
  background: #ffffff;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
  transition: all 0.2s ease;
}

.btn-topbar-restore:hover {
  background: #f0f4ef;
  color: var(--green);
  border-color: var(--green);
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(33, 74, 64, 0.12);
}

.breadcrumb {
  font-size: 12px;
  color: #8a918e
}

.breadcrumb i {
  font-style: normal;
  margin: 0 9px;
  color: #c5c8c4
}

.breadcrumb strong {
  color: var(--ink);
  font-weight: 600
}

.crumb-subtitle {
  font-size: 11.5px;
  font-weight: 400;
  color: #717d77;
  margin-left: 6px;
  transition: color 0.2s ease;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 14px
}

.lang-switcher {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  color: #66706b;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  color: var(--ink);
}

.lang-btn.active {
  background: #ffffff;
  color: var(--ink);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.status-dot {
  font-size: 10px;
  color: #75807c;
  display: flex;
  align-items: center;
  gap: 7px
}

.status-dot i {
  width: 7px;
  height: 7px;
  background: #4aaa69;
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(74, 170, 105, .12)
}

.icon-button {
  border: 0;
  background: none;
  position: relative;
  font-size: 20px;
  color: #515d58
}

.icon-button span {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  right: 2px;
  top: 2px
}

.menu-toggle {
  display: none;
  border: 0;
  background: none;
  font-size: 20px
}

.view {
  display: none;
  padding: 10px 24px 0;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  flex: 1 0 auto;
  box-sizing: border-box;
}

.view.active {
  display: block
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 210px;
  position: relative;
  margin-bottom: 24px;
}

.eyebrow {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .19em;
  color: #74807b;
  font-weight: 700;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 8px
}

.eyebrow span:first-child {
  width: 22px;
  height: 2px;
  background: var(--accent)
}

.hero h1,
.section-head h1,
.chat-header h1 {
  font-family: "Noto Sans TC", sans-serif;
  font-size: 39px;
  line-height: 1.3;
  letter-spacing: -.035em;
  margin: 0;
  font-weight: 800
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
  position: relative
}

.hero h1 em:after {
  content: "";
  position: absolute;
  left: 0;
  right: 2px;
  bottom: -3px;
  height: 5px;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 8' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 6Q50 1 99 5T199 3' fill='none' stroke='%23df5b38' stroke-width='2'/%3E%3C/svg%3E") center/100% 100%
}

.hero-copy {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.8;
  margin: 16px 0 0
}

.hero-art {
  width: 280px;
  height: 190px;
  position: relative;
  margin-right: 40px
}

.orbit {
  position: absolute;
  border: 1px solid #d5d8ce;
  border-radius: 50%;
  transform: rotate(-18deg)
}

.orbit-a {
  inset: 15px 15px
}

.orbit-b {
  inset: 43px -8px 35px 20px;
  transform: rotate(24deg)
}

.book {
  position: absolute;
  left: 91px;
  top: 62px;
  width: 105px;
  height: 72px;
  transform: rotate(-8deg);
  background: var(--green);
  border-radius: 4px 8px 8px 4px;
  box-shadow: 12px 12px 0 #e4ddce
}

.book:before {
  content: "";
  position: absolute;
  inset: 9px;
  background: #f5f1df;
  border-radius: 2px
}

.book:after {
  content: "";
  position: absolute;
  left: 51px;
  top: 9px;
  bottom: 9px;
  border-left: 1px solid #b8b7a8
}

.book span,
.book i {
  position: absolute;
  z-index: 1;
  height: 2px;
  background: #ccd0bd;
  width: 31px;
  top: 28px
}

.book span {
  left: 14px
}

.book i {
  right: 13px
}

.spark {
  position: absolute;
  color: var(--accent)
}

.s1 {
  left: 39px;
  top: 46px;
  font-size: 24px
}

.s2 {
  right: 25px;
  top: 22px;
  font-size: 16px;
  color: var(--lime)
}

.s3 {
  right: 17px;
  bottom: 20px;
  font-size: 28px
}

.steps {
  height: 60px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  margin-bottom: 18px
}

.step {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 170px;
  opacity: .42
}

.step.active,
.step.done {
  opacity: 1
}

.step>span {
  font-size: 10px;
  font-weight: 700;
  width: 29px;
  height: 29px;
  border: 1px solid #aeb5b1;
  border-radius: 50%;
  display: grid;
  place-items: center
}

.step.active>span {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent)
}

.step.done>span {
  background: var(--green);
  color: #fff;
  border-color: var(--green)
}

.step b {
  display: block;
  font-size: 12px
}

.step small {
  font-size: 9px;
  color: #8d9692
}

.steps>i {
  height: 1px;
  background: #d6d9d4;
  flex: 1;
  margin: 0 21px;
  position: relative
}

.steps>i:after {
  content: "";
  position: absolute;
  right: 0;
  top: -2px;
  width: 4px;
  height: 4px;
  border-top: 1px solid #aaa;
  border-right: 1px solid #aaa;
  transform: rotate(45deg)
}

.workspace-steps {
  height: 60px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
  padding: 0;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 22px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
  padding: 22px 24px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 21px
}

.panel-heading>div {
  display: flex;
  align-items: center;
  gap: 12px
}

.panel-index {
  font-size: 10px;
  color: var(--accent);
  font-weight: 700
}

.panel h2 {
  font-size: 16px;
  margin: 0
}

.secure,
.lock {
  font-size: 9px;
  color: #71827a;
  background: #edf1eb;
  padding: 5px 8px;
  border-radius: 3px
}

.dropzone {
  height: 155px;
  border: 1px dashed #b8bdb7;
  background: #f6f6f1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: .2s;
  position: relative;
  padding: 12px;
}

.dropzone:hover,
.dropzone.dragging {
  border-color: var(--accent);
  background: #fff8f4;
  transform: translateY(-2px)
}

.dropzone input {
  position: absolute;
  opacity: 0;
  pointer-events: none
}

.upload-icon {
  width: 47px;
  height: 47px;
  border-radius: 50%;
  background: #e8ebe3;
  display: grid;
  place-items: center;
  margin-bottom: 12px
}

.upload-icon i {
  font-style: normal;
  font-size: 22px;
  color: var(--green)
}

.dropzone strong {
  font-size: 13px
}

.dropzone p {
  font-size: 10px;
  color: #8b9390;
  margin: 5px 0 11px
}

.dropzone small {
  font-size: 8px;
  color: #9ca39f
}

.demo-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 17px;
  font-size: 10px;
  color: #8a928e
}

.demo-row button {
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 10px;
  cursor: pointer;
  font-weight: 600
}

.demo-row b {
  margin-left: 5px
}

.settings-panel {
  transition: .3s
}

.settings-panel.locked .form-grid,
.settings-panel.locked .primary-button,
.settings-panel.locked .estimate {
  opacity: .42;
  pointer-events: none
}

.file-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0 0;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: all 0.2s ease;
}

.file-card.hidden {
  display: none !important;
}

.pdf-icon {
  background: #df5b38;
  color: #fff;
  width: 34px;
  height: 34px;
  font-size: 10px;
  font-weight: 800;
  border-radius: 6px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(223, 91, 56, 0.22);
}

.file-card .file-card-info {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.file-card b {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.4;
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: normal;
}

.file-card small {
  display: block;
  color: #64748b;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.3;
}

.file-card button {
  border: 0;
  background: transparent;
  color: #94a3b8;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-card button:hover {
  background: #fee2e2;
  color: #ef4444;
}

.file-parsed-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 0 4px;
}

.file-parsed-status-row.hidden {
  display: none !important;
}

.file-parsed-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2.5px 8px;
  border-radius: 4px;
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.file-parsed-hint {
  color: #64748b;
  font-size: 11px;
  line-height: 1.3;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px 13px
}

.form-grid label>span {
  display: block;
  font-size: 9px;
  font-weight: 600;
  color: #59635e;
  margin-bottom: 7px
}

.form-grid select {
  width: 100%;
  appearance: none;
  border: 1px solid #dadcd6;
  background: #f8f8f5 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='m3 5 3 3 3-3' fill='none' stroke='%23666'/%3E%3C/svg%3E") no-repeat right 10px center;
  padding: 10px 12px;
  border-radius: 3px;
  color: #343d39;
  font-size: 10px
}

.primary-button,
.secondary-button {
  border: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 700;
  transition: .2s
}

.primary-button {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 7px 18px rgba(223, 91, 56, .2)
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px)
}

.primary-button:disabled,
.disabled {
  opacity: .42;
}

.download-actions .disabled {
  opacity: .42;
  cursor: not-allowed;
  pointer-events: auto !important;
}

.settings-panel>.primary-button {
  width: 100%;
  height: 42px;
  margin-top: 20px;
  position: relative
}

.primary-button i {
  font-style: normal;
  position: absolute;
  right: 15px
}

.estimate {
  text-align: center;
  color: #999f9c;
  font-size: 8px;
  margin: 8px 0 0
}

.value-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-top: 27px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 17px 0
}

.value-strip>div {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 20px;
  border-right: 1px solid var(--line)
}

.value-strip>div:last-child {
  border: 0
}

.value-strip>div>span {
  font-size: 9px;
  color: var(--accent);
  font-weight: 700
}

.value-strip p {
  margin: 0
}

.value-strip b {
  display: block;
  font-size: 10px
}

.value-strip small {
  font-size: 8px;
  color: #8b9490
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 32px
}

.section-head h1,
.chat-header h1 {
  font-size: 31px
}

.section-head>div>p:last-child,
.chat-header>div>p:last-child {
  font-size: 12px;
  color: var(--muted)
}

.download-actions {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: nowrap;
  flex-shrink: 0;
}

.download-actions a,
.download-actions button {
  height: 29px;
  padding: 0 8px;
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}

.secondary-button {
  border: 1px solid #ccd0ca;
  color: var(--green);
  background: #fafaf7
}

.deck-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 25px
}

.slide-list {
  height: calc(100vh - 210px);
  overflow: auto;
  padding-right: 8px
}

.slide-thumb {
  background: #fff;
  border: 1px solid var(--line);
  margin-bottom: 12px;
  padding: 8px;
  cursor: pointer;
  transition: .2s;
  position: relative
}

.slide-thumb.active {
  border: 2px solid var(--accent);
  padding: 7px
}

.slide-thumb small {
  position: absolute;
  left: -19px;
  top: 4px;
  font-size: 8px;
  color: #8d9491
}

.mini-slide {
  aspect-ratio: 16/9;
  background: #f4f3ed;
  padding: 10px;
  overflow: hidden
}

.mini-slide b {
  display: block;
  font-size: 8px;
  line-height: 1.3;
  margin-bottom: 6px
}

.mini-slide i {
  display: block;
  width: 65%;
  height: 3px;
  background: #c5cbc4;
  margin: 4px 0
}

.empty-mini {
  text-align: center;
  color: #999;
  font-size: 10px;
  padding: 40px 0
}

.slide-stage-wrap {
  min-width: 0
}

.slide-stage {
  aspect-ratio: 16/9;
  background: #f8f7f1;
  box-shadow: 0 16px 55px rgba(28, 40, 34, .14);
  border: 1px solid #e1e1da;
  position: relative;
  overflow: hidden;
  padding: 6% 6% 5% 7.5%;
  display: flex;
  flex-direction: column;
  justify-content: center
}

.slide-stage:before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 8px;
  background: var(--accent)
}

.slide-stage:after {
  content: attr(data-page);
  position: absolute;
  right: 5%;
  top: 6%;
  font-size: 12px;
  color: var(--accent);
  font-weight: 700
}

.slide-stage h2 {
  font-family: "Noto Sans TC";
  font-size: clamp(18px, 2.3vw, 33px);
  line-height: 1.25;
  margin: 0 0 2.5%;
  max-width: 96%
}

.slide-title-icon {
  margin-right: 8px;
  font-size: 1.35em;
  vertical-align: middle;
  display: inline-block;
  line-height: 1;
}

.slide-content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  align-items: center;
}

.slide-content-grid.has-visual {
  grid-template-columns: 1.2fr 1fr;
  gap: 12px;
  align-items: center;
}

.visual-card {
  width: 100%;
  background: #ffffff;
  border: 1.5px solid #de5b37;
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.04);
  font-family: "Noto Sans TC", sans-serif;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-sizing: border-box;
}

.visual-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: clamp(12px, 1.2vw, 15px);
  font-weight: 700;
  color: #de5b37;
  border-bottom: 1px solid #fce8e2;
  padding-bottom: 6px;
  margin-bottom: 2px;
}

.visual-card-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.visual-step-box {
  border-radius: 8px;
  padding: 8px 12px;
  border: 1px solid #cbd5e0;
  background: #f7fafc;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.visual-step-box:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.visual-step-box.step-idx-0 {
  background: #fff5f2;
  border-color: #de5b37;
}

.visual-step-box.step-idx-0 .visual-step-label {
  color: #de5b37;
}

.visual-step-box.step-idx-1 {
  background: #edf2f7;
  border-color: #4a5568;
}

.visual-step-box.step-idx-1 .visual-step-label {
  color: #4a5568;
}

.visual-step-box.step-idx-2 {
  background: #f7fafc;
  border-color: #a0aec0;
}

.visual-step-box.step-idx-2 .visual-step-label {
  color: #2b6cb0;
}

.visual-step-label {
  font-size: clamp(11px, 1vw, 12px);
  font-weight: 700;
  margin-bottom: 2px;
}

.visual-step-text {
  font-size: clamp(11.5px, 0.95vw, 13px);
  line-height: 1.45;
  color: #2d3748;
  outline: none;
}

.visual-step-text:focus,
.visual-takeaway-text:focus {
  background: rgba(255, 255, 255, 0.8);
  box-shadow: inset 0 0 0 1px #de5b37;
  border-radius: 4px;
}

.visual-card-takeaway {
  background: #f0f9ff;
  border: 1px solid #2b6cb0;
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.visual-takeaway-head {
  font-size: clamp(11px, 1vw, 12px);
  font-weight: 700;
  color: #2b6cb0;
}

.visual-takeaway-text {
  font-size: clamp(11.5px, 0.95vw, 12.5px);
  line-height: 1.45;
  color: #2d3748;
  outline: none;
}

.visual-diagram-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding-left: 0;
}

.slide-stage ul {
  margin: 0;
  padding: 0;
  list-style: none
}

.slide-stage li {
  font-size: clamp(12px, 1.6vw, 21px);
  margin: 2.2% 0;
  color: #42504a;
  padding-left: 24px;
  position: relative
}

.slide-stage li:before {
  content: "";
  position: absolute;
  left: 2px;
  top: .55em;
  width: 7px;
  height: 7px;
  background: var(--lime);
  transform: rotate(45deg)
}

.stage-empty {
  margin: auto;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: #85908a
}

.stage-empty span {
  font-size: 36px
}

.stage-empty b {
  font-size: 15px
}

.stage-empty small {
  font-size: 10px
}

.speaker-notes {
  background: #fff;
  border: 1px solid var(--line);
  margin-top: 16px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-radius: 8px;
}

.notes-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}

.notes-label {
  display: flex;
  align-items: center;
  gap: 8px;
  border-right: none;
}

.notes-label span {
  display: inline-grid;
  place-items: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 11px;
}

.notes-label b {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.notes-label small {
  display: inline-block;
  margin: 0 0 0 6px;
  color: #8d9692;
  font-size: 11px;
}

.speaker-notes p {
  font-family: "Noto Sans TC";
  font-size: 11px;
  line-height: 1.8;
  color: #59645f;
  margin: 0
}

.chat-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 16px;
}

.document-chip {
  background: #fbfbf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  min-width: 220px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.document-chip>span {
  background: var(--accent);
  color: #fff;
  font-size: 8px;
  font-weight: 700;
  padding: 4px 6px;
  border-radius: 4px;
}

.document-chip b {
  display: block;
  font-size: 11px;
  color: var(--ink);
}

.document-chip small {
  font-size: 9.5px;
  color: #8c9490;
}

/* 教材問答與 AI 備課助手專屬全螢幕固定底欄對話佈局 */
#chatView.active,
#agentView.active {
  display: flex !important;
  flex-direction: column !important;
  height: calc(100vh - 68px) !important;
  height: calc(100dvh - 68px) !important;
  max-height: calc(100vh - 68px) !important;
  max-height: calc(100dvh - 68px) !important;
  padding: 10px 24px 10px !important;
  overflow: hidden !important;
  box-sizing: border-box !important;
  gap: 8px !important;
}

.topbar.collapsed ~ #chatView.active,
.topbar.collapsed ~ #agentView.active {
  height: 100vh !important;
  height: 100dvh !important;
  max-height: 100vh !important;
  max-height: 100dvh !important;
  padding: 8px 20px 8px !important;
}

/* 頂部極簡工具列 */
.chat-top-toolbar,
.agent-top-toolbar {
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 4px 4px 4px;
  background: transparent;
  border: none;
  border-radius: 0;
  min-height: 38px;
  gap: 12px;
  box-shadow: none;
}

.chat-toolbar-left,
.chat-toolbar-right,
.agent-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.document-chip.compact {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px;
  background: #fbfbf8;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}

.document-chip.compact span {
  background: var(--green);
  color: #fff;
  font-weight: 700;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
}

.document-chip.compact b {
  font-size: 12px;
  color: var(--ink);
  font-weight: 600;
  display: inline-block;
}

.document-chip.compact small {
  display: none;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #ffffff;
  border: 1px solid #d8dbd5;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 12px;
  color: #56615c;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  background: #f4f6f2;
  border-color: #bec3bb;
  color: var(--ink);
}

.toolbar-btn span.icon {
  font-size: 12px;
}

.agent-dept-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.chat-shell,
.agent-chat-shell {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  height: auto !important;
  max-height: none !important;
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  border-radius: 12px !important;
  background: #ffffff !important;
  border: 1px solid var(--line) !important;
  box-shadow: var(--shadow) !important;
}

.messages {
  flex: 1 1 0% !important;
  min-height: 0 !important;
  overflow-y: auto !important;
  padding: 16px 4% 12px !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 16px !important;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 820px;
  animation: fadeIn 0.25s ease-out;
}

.follow-up-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(0, 0, 0, 0.08);
}

.follow-up-label {
  width: 100%;
  font-size: 11px;
  color: #717d77;
  font-weight: 600;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.follow-up-chip {
  background: #ffffff;
  border: 1px solid #d2d7cf;
  border-radius: 14px;
  padding: 4px 10px;
  font-size: 11px;
  color: #375047;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.follow-up-chip:hover {
  background: #f0f5ee;
  border-color: var(--green);
  color: var(--green);
  transform: translateY(-1px);
  box-shadow: 0 2px 5px rgba(33, 74, 64, 0.08);
}

.message.user {
  margin-left: auto;
  flex-direction: row-reverse;
}

.message.user>div {
  background: var(--green);
  color: #fff;
  padding: 10px 15px;
  border-radius: 14px 2px 14px 14px;
  font-size: 12.5px;
  line-height: 1.5;
  box-shadow: 0 2px 6px rgba(33, 74, 64, 0.12);
}

.bot-avatar {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--lime);
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
}

.message.assistant>div {
  background: #fbfbf8;
  border: 1px solid var(--line);
  padding: 12px 16px;
  border-radius: 2px 14px 14px 14px;
  min-width: 0;
  font-size: 13px;
  line-height: 1.55;
  box-shadow: 0 1px 4px rgba(33, 74, 64, 0.03);
}

.suggestions {
  display: flex;
  gap: 7px;
  flex-wrap: wrap;
  margin-top: 12px
}

.suggestions button {
  border: 1px solid #d7dad4;
  background: #fff;
  padding: 7px 10px;
  border-radius: 15px;
  color: #56615c;
  font-size: 9px;
  cursor: pointer
}

.source-list {
  border-top: 1px solid #dbded7;
  margin-top: 12px;
  padding-top: 10px
}

.source-list>span {
  font-size: 8px;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: #8a938e
}

.source {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 8px
}

.source b {
  background: #e4e9df;
  color: #375047;
  padding: 3px 6px;
  border-radius: 2px;
  white-space: nowrap;
  font-size: 8px !important
}

.source p {
  margin: 0 !important;
  font-size: 9px !important;
  line-height: 1.5 !important
}

/* === Dynamic Multi-stage Loading Pipeline (Self-RAG & Agent) === */
.stage-pipeline {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 8px;
  padding: 10px 14px;
  background: #f4f7f4;
  border: 1px solid #e1e7e2;
  border-radius: 8px;
  min-width: 280px;
}

.stage-step {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  color: #8b9691;
  transition: all 0.25s ease;
}

.stage-step.active {
  color: var(--green);
  font-weight: 600;
}

.stage-step.done {
  color: #4a5a53;
}

.stage-indicator {
  width: 17px;
  height: 17px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9.5px;
  flex-shrink: 0;
  background: #e2e8e4;
  color: #8b9691;
  transition: all 0.2s ease;
}

.stage-step.active .stage-indicator {
  background: #d1fae5;
  color: #065f46;
  border: 1.5px solid #10b981;
  animation: stagePulse 1.2s infinite ease-in-out;
}

.stage-step.done .stage-indicator {
  background: #10b981;
  color: #ffffff;
  font-weight: 700;
}

@keyframes stagePulse {
  0%, 100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0);
  }
}

.chat-input {
  border-top: 1px solid var(--line);
  padding: 14px 24px 12px;
  background: #fff;
  position: relative;
}

.chat-input-box {
  position: relative;
  width: 100%;
}

.chat-input textarea {
  width: 100%;
  resize: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
  border: 1px solid #d8dbd5;
  background: #f9f9f6;
  border-radius: 10px;
  padding: 11px 48px 11px 14px;
  outline: none;
  font-size: 13.5px;
  line-height: 1.5;
  min-height: 44px;
  max-height: 48vh !important;
  font-family: inherit;
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input textarea::-webkit-scrollbar {
  width: 5px;
  height: 0px;
}

.chat-input textarea::-webkit-scrollbar-track {
  background: transparent;
}

.chat-input textarea::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.chat-input textarea::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.chat-input textarea:focus {
  border-color: var(--green);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(33, 74, 64, 0.08);
}

.chat-input button {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chat-input button:hover:not(:disabled) {
  background: #c84e2e;
  transform: translateY(-50%) scale(1.04);
}

.chat-input button:disabled {
  background: #d1d5db;
  cursor: not-allowed;
  transform: translateY(-50%);
  opacity: 0.6;
}

.chat-input small {
  display: block;
  text-align: center;
  font-size: 9.5px;
  color: #a0a6a3;
  margin-top: 6px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: #203f37;
  color: #fff;
  padding: 13px 17px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, .2);
  z-index: 50;
  transform: translateY(90px);
  opacity: 0;
  transition: .3s
}

.toast.show {
  transform: none;
  opacity: 1
}

.toast span {
  color: var(--lime)
}

.toast p {
  margin: 0;
  font-size: 11px
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(244, 243, 237, .94);
  backdrop-filter: blur(6px);
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column
}

.loading-overlay.hidden {
  display: none
}

.loader-mark {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  width: 62px;
  height: 62px;
  padding: 14px;
  background: var(--lime);
  margin-bottom: 20px;
  animation: float 1.5s ease-in-out infinite
}

.loader-mark i {
  display: block;
  width: 8px;
  background: var(--green);
  animation: bars 1s ease-in-out infinite
}

.loader-mark i:nth-child(1) {
  height: 18px
}

.loader-mark i:nth-child(2) {
  height: 32px;
  animation-delay: .15s
}

.loader-mark i:nth-child(3) {
  height: 25px;
  animation-delay: .3s
}

.loading-overlay b {
  font-family: "Noto Sans TC";
  font-size: 18px
}

.loading-overlay p {
  font-size: 11px;
  color: var(--muted)
}

.loading-track {
  width: 240px;
  height: 3px;
  background: #d9ddd5;
  margin-top: 12px;
  overflow: hidden
}

.loading-track span {
  display: block;
  height: 100%;
  width: 45%;
  background: var(--accent);
  animation: load 1.4s ease-in-out infinite
}

@keyframes bars {
  50% {
    height: 10px
  }
}

@keyframes float {
  50% {
    transform: translateY(-5px) rotate(2deg)
  }
}

@keyframes load {
  0% {
    transform: translateX(-110%)
  }

  100% {
    transform: translateX(240%)
  }
}

@media(max-width:950px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 24px rgba(0, 0, 0, 0.3);
  }

  .menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    font-size: 22px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--ink);
    cursor: pointer;
  }

  .topbar {
    padding: env(safe-area-inset-top, 0px) 16px 0;
    justify-content: flex-start;
    gap: 12px;
  }

  .btn-topbar-restore {
    right: max(16px, env(safe-area-inset-right, 0px));
    top: max(8px, env(safe-area-inset-top, 0px));
  }

  .top-actions {
    margin-left: auto;
    gap: 10px;
  }

  main {
    margin-left: 0;
  }

  .view {
    padding: 24px 16px;
  }

  .hero-art {
    display: none;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .value-strip {
    grid-template-columns: 1fr;
    gap: 13px;
  }

  .value-strip>div {
    border: 0;
  }

  .deck-layout {
    grid-template-columns: 130px 1fr;
  }

  .chat-header {
    align-items: flex-start;
    gap: 20px;
  }
}

@media(max-width:650px) {
  .topbar .breadcrumb {
    display: none;
  }

  .top-actions {
    gap: 6px;
  }

  .status-dot span {
    display: none;
  }

  .status-dot {
    gap: 0;
    padding: 0 4px;
  }

  .lang-switcher {
    padding: 1px;
    gap: 1px;
    border-radius: 8px;
  }

  .lang-btn {
    padding: 4px 6px;
    font-size: 10px;
    min-height: 28px;
    border-radius: 6px;
  }

  .auth-btn {
    padding: 5px 8px;
    font-size: 10.5px;
    min-height: 28px;
    border-radius: 6px;
  }

  .auth-user-chip {
    padding: 3px 8px;
    gap: 5px;
    font-size: 10.5px;
    max-width: 175px;
  }

  .auth-user-chip strong {
    max-width: 65px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.5px;
  }

  .auth-tier-badge {
    font-size: 9.5px;
    padding: 1px 5px;
    background: #eef1ec;
    border-radius: 8px;
    color: var(--green);
    font-weight: 700;
    white-space: nowrap;
  }

  .auth-logout-btn {
    padding: 2px 5px;
    font-size: 9.5px;
  }

  .hero {
    min-height: 200px;
    padding: 10px 0;
  }

  .home-hero-actions {
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    gap: 10px;
  }

  .home-hero-actions button {
    width: 100%;
    justify-content: center;
    padding: 12px 18px;
    min-height: 44px;
  }

  .hero h1 {
    font-size: 26px;
    line-height: 1.3;
  }

  .hero h1 br,
  .hero-copy br {
    display: none;
  }

  .steps {
    padding: 10px 12px;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .steps .step {
    min-width: 0;
    gap: 6px;
  }

  .steps .step div {
    display: flex;
    flex-direction: column;
  }

  .steps .step b {
    font-size: 11px;
    white-space: nowrap;
  }

  .steps .step small {
    display: none;
  }

  .steps>i {
    margin: 0 4px;
    flex-shrink: 0;
  }

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

  .deck-layout {
    display: block;
  }

  .slide-list {
    display: flex;
    height: auto;
    overflow-x: auto;
    margin-bottom: 15px;
    -webkit-overflow-scrolling: touch;
  }

  .slide-thumb {
    min-width: 120px;
    margin-right: 10px;
  }

  .section-head,
  .chat-header {
    display: block;
  }

  .download-actions {
    margin-top: 16px;
  }

  .document-chip {
    margin-top: 18px;
  }

  #chatView.active,
  #agentView.active {
    height: calc(100vh - 60px) !important;
    height: calc(100dvh - 60px) !important;
    max-height: calc(100vh - 60px) !important;
    max-height: calc(100dvh - 60px) !important;
    padding: 12px 14px 8px !important;
  }

  .agent-dept-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Hide metric cards ONLY in Agent Ops view on mobile to save vertical layout space */
  #agentView .admin-metrics-grid {
    display: none !important;
  }

  /* Admin Console Metrics Grid - Compact 3-Column Layout on Mobile */
  #adminView .admin-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    margin-bottom: 14px !important;
  }

  #adminView .admin-metric-card {
    padding: 8px 4px;
    border-radius: 10px;
    gap: 4px;
    flex-direction: column;
    text-align: center;
    align-items: center;
  }

  #adminView .admin-metric-card .metric-icon {
    width: 26px;
    height: 26px;
    min-width: 26px;
    font-size: 13px;
    border-radius: 8px;
  }

  #adminView .admin-metric-card div b {
    font-size: 14px;
    line-height: 1.1;
  }

  #adminView .admin-metric-card div small {
    font-size: 9px;
    white-space: nowrap;
  }

  .messages {
    padding: 14px 10px 10px !important;
  }

  .topbar .status-dot {
    display: none;
  }

  .auth-modal-card {
    padding: 22px 18px;
    max-width: 95%;
  }

  .auth-modal-close {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    top: 10px;
    right: 10px;
  }

  .admin-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}



/* --- Provider Card Styles --- */
.provider-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.08);
  border-radius: 6px;
  padding: 5px 8px;
  margin-top: 0;
  margin-bottom: 4px;
}

.provider-head {
  display: flex;
  align-items: center;
  margin-bottom: 3px;
}

.provider-head span {
  font-size: 11.5px;
  font-weight: 600;
  color: #aec0ba;
  display: flex;
  align-items: center;
  gap: 5px;
  letter-spacing: 0.02em;
}

.provider-select-wrapper {
  position: relative;
}

.provider-select {
  width: 100%;
  appearance: none;
  background: rgba(255, 255, 255, 0.08) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10'%3E%3Cpath d='m2 4 3 3 3-3' fill='none' stroke='%23aec0ba'/%3E%3C/svg%3E") no-repeat right 8px center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: #fff;
  font-size: 11.5px !important;
  line-height: 1.25 !important;
  padding: 4px 7px !important;
  height: 26px !important;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  -webkit-text-size-adjust: none;
}

.provider-select:hover {
  border-color: rgba(255, 255, 255, 0.35);
  background-color: rgba(255, 255, 255, 0.14);
}

.provider-select:focus {
  border-color: var(--lime);
  box-shadow: 0 0 0 2px rgba(201, 215, 101, 0.2);
}

.provider-select option {
  background: #1f3e36;
  color: #fff;
  padding: 4px 6px !important;
  font-size: 11.5px !important;
}

.multimodal-card {
  margin-top: 6px;
  background: rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  padding: 6px 8px 8px;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.multimodal-card:hover {
  border-color: rgba(201, 215, 101, 0.3);
  background-color: rgba(0, 0, 0, 0.16);
}

.multimodal-card.feature-locked {
  background: rgba(217, 119, 6, 0.1) !important;
  border: 1px solid rgba(217, 119, 6, 0.3) !important;
}

.multimodal-card.feature-locked:hover {
  background: rgba(217, 119, 6, 0.15) !important;
  border-color: rgba(217, 119, 6, 0.5) !important;
}

.multimodal-card.feature-locked .switch {
  opacity: 0.5;
  cursor: not-allowed;
}

.multimodal-card.feature-locked .switch input {
  cursor: not-allowed;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 3px;
}

.toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-title {
  font-size: 11px;
  font-weight: 500;
  color: #e2e8f0;
  letter-spacing: 0.01em;
}

.toggle-hint {
  font-size: 9.5px;
  color: #889995;
  line-height: 1.25;
}

/* --- Modern Sliding Switch Pill --- */
.switch {
  position: relative;
  display: inline-block;
  width: 34px;
  height: 18px;
  flex-shrink: 0;
  cursor: pointer;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  margin: 0;
}

.switch .slider {
  position: absolute;
  inset: 0;
  background-color: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.3);
}

.switch .slider::before {
  position: absolute;
  content: "";
  height: 12px;
  width: 12px;
  left: 2px;
  bottom: 2px;
  background-color: #cbd5e1;
  border-radius: 50%;
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.switch input:checked + .slider {
  background-color: var(--lime, #c9d765);
  border-color: rgba(201, 215, 101, 0.6);
  box-shadow: 0 0 8px rgba(201, 215, 101, 0.3);
}

.switch input:checked + .slider::before {
  transform: translateX(16px);
  background-color: #19221f;
}

.switch:hover .slider {
  border-color: rgba(255, 255, 255, 0.35);
}

.switch input:focus-visible + .slider {
  outline: 2px solid var(--lime, #c9d765);
  outline-offset: 2px;
}

/* --- Auth Header & Modal Styles --- */
.auth-header-container {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-btn {
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: .2s;
}

.auth-btn:hover {
  background: #254b42;
}

.auth-user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fafaf7;
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
}

.auth-user-chip strong {
  color: var(--green);
}

.auth-user-chip small,
.auth-tier-badge {
  color: var(--green);
  font-size: 10px;
  font-weight: 600;
  background: #eef1ec;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}

.auth-logout-btn {
  background: transparent;
  border: 1px solid #d0d6d2;
  color: #63706a;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 10px;
  cursor: pointer;
  transition: .2s;
}

.auth-logout-btn:hover {
  background: #f0f3ee;
  color: #d9534f;
  border-color: #d9534f;
}

/* Auth Modal Window */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 30, 26, 0.6);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-modal-overlay.hidden {
  display: none;
}

.auth-modal-card {
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  border-radius: 14px;
  width: 100%;
  max-width: 400px;
  padding: 28px 30px;
  position: relative;
  animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.auth-modal-card.auth-split-card {
  max-width: 900px;
  padding: 0;
  display: flex;
  overflow: hidden;
  border-radius: 18px;
}

.auth-brand-pane {
  flex: 1.3;
  background: radial-gradient(circle at 85% 15%, rgba(223, 91, 56, 0.14), transparent 45%),
              radial-gradient(circle at 15% 85%, rgba(33, 74, 64, 0.09), transparent 50%),
              var(--panel);
  padding: 36px 26px;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.auth-brand-title {
  font-size: 23px;
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 8px 0;
  color: var(--ink);
  letter-spacing: -0.02em;
}

.auth-brand-title em {
  font-style: normal;
  color: var(--accent);
  position: relative;
  display: inline-block;
}

.auth-brand-title em:after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0px;
  height: 6px;
  background: rgba(223, 91, 56, 0.2);
  border-radius: 4px;
  z-index: -1;
}

.auth-brand-copy {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.5;
  margin: 0;
}

.auth-brand-art {
  width: 100%;
  height: 135px;
  position: relative;
  margin: 10px 0 16px 0;
  transform: scale(0.85);
  transform-origin: center center;
}

.auth-brand-steps {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(220, 225, 218, 0.9);
  border-radius: 12px;
  padding: 10px 12px;
}

.auth-step-item {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.auth-step-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-step-item b {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.25;
  white-space: nowrap;
}

.auth-step-item small {
  display: block;
  font-size: 9px;
  color: var(--muted);
  line-height: 1.25;
  white-space: nowrap;
  letter-spacing: -0.015em;
}

.auth-step-arrow {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  text-align: center;
}

.auth-form-pane {
  flex: 1;
  padding: 38px 34px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 768px) {
  .auth-modal-card.auth-split-card {
    flex-direction: column;
    max-width: 420px;
  }
  .auth-brand-pane {
    display: none;
  }
  .auth-form-pane {
    padding: 28px 24px;
  }
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-modal-close {
  position: absolute;
  right: 18px;
  top: 18px;
  background: transparent;
  border: 0;
  font-size: 22px;
  color: #8c9490;
  cursor: pointer;
  line-height: 1;
}

.auth-modal-close:hover {
  color: #203f37;
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--line);
  margin-bottom: 22px;
}

.auth-tab-btn {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 0;
  font-size: 13px;
  font-weight: 600;
  color: #78827d;
  cursor: pointer;
  transition: .2s;
}

.auth-tab-btn.active {
  color: var(--green);
  border-bottom-color: var(--accent);
}

.auth-form h3 {
  margin: 0 0 4px;
  font-size: 18px;
  color: #1a2a24;
}

.auth-sub {
  margin: 0 0 18px;
  font-size: 11px;
  color: #737c77;
  line-height: 1.5;
}

.auth-field {
  margin-bottom: 14px;
}

.auth-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #404d47;
  margin-bottom: 5px;
}

.auth-field input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d4d8d2;
  border-radius: 4px;
  background: #f9f9f6;
  font-size: 12px;
  outline: none;
  transition: .2s;
}

.auth-field input:focus {
  border-color: var(--green);
  background: #fff;
}

.auth-error-msg {
  background: #fdf2f2;
  border: 1px solid #f8b4b4;
  color: #9b1c1c;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 11px;
  margin-bottom: 14px;
}

.auth-success-msg {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 11px;
  margin-bottom: 14px;
}

.auth-submit-btn {
  width: 100%;
  height: 38px;
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
}

.auth-hint {
  font-size: 10px;
  color: #88908b;
  margin-top: 14px;
  text-align: center;
}

.auth-hint code {
  background: #f0f2ee;
  padding: 1px 5px;
  border-radius: 3px;
  color: var(--green);
}

/* === Home View / Product Showcase Styles === */
.home-hero-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 22px;
  flex-wrap: wrap;
}

.home-features-section {
  margin: 28px 0 24px 0;
}

.home-features-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .home-features-grid {
    grid-template-columns: 1fr;
  }
}

.home-feature-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
  display: flex;
  gap: 14px;
  align-items: flex-start;
  transition: all 0.2s ease;
  cursor: pointer;
}

.home-feature-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(223, 91, 56, 0.1);
}

.home-feature-card .feat-icon {
  font-size: 22px;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: #f1f5f3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #dce4e0;
}

.home-feature-card h3 {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 4px 0;
}

.home-feature-card p {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0;
}

.home-feature-card .feat-arrow {
  margin-left: auto;
  color: #94a3b8;
  font-size: 14px;
  font-weight: 700;
  transition: transform 0.2s ease, color 0.2s ease;
}

.home-feature-card:hover .feat-arrow {
  color: var(--accent);
  transform: translateX(4px);
}

/* === Admin Control Dashboard & Profile Settings Styles === */

.admin-only.hidden {
  display: none !important;
}

.nav-item.admin-only {
  color: #d97706;
  font-weight: 600;
}

.nav-item.admin-only:hover {
  background: #fef3c7;
  color: #b45309;
}

.badge-pending,
.badge-count {
  background: #ef4444;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: auto;
}

.admin-modal-card {
  max-width: 720px;
  width: 92%;
}

.admin-modal-header h2 {
  font-size: 16px;
  color: #111827;
  margin-bottom: 4px;
}

.admin-modal-header p {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 12px;
}

.admin-table-wrapper {
  margin-top: 10px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  max-height: none;
  overflow-y: visible;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  text-align: left;
}

.admin-table th {
  background: #f9fafb;
  color: #374151;
  padding: 8px 12px;
  font-weight: 600;
  border-bottom: 1px solid #e5e7eb;
  position: sticky;
  top: 0;
  z-index: 1;
}

.admin-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f3f4f6;
  color: #1f2937;
  vertical-align: middle;
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.btn-sm {
  padding: 3px 8px;
  font-size: 10px;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  transition: opacity 0.15s ease;

  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-right: 4px;
}

.btn-sm:hover {
  opacity: 0.85;
}

.btn-approve {
  background: #10b981;
  color: white;
}

.btn-reject {
  background: #ef4444;
  color: white;
}

.btn-action {
  background: #3b82f6;
  color: white;
}

.btn-warning {
  background: #f59e0b;
  color: white;
}

.role-chip {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

.role-chip.admin {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fcd34d;
}

.role-chip.user {
  background: #e0f2fe;
  color: #0369a1;
  border: 1px solid #bae6fd;
}

.status-chip {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
}

.status-chip.approved {
  background: #d1fae5;
  color: #065f46;
}

.status-chip.pending {
  background: #fee2e2;
  color: #991b1b;
}

.status-chip.rejected {
  background: #f3f4f6;
  color: #4b5563;
}

.modal-divider {
  border: none;
  border-top: 1px solid #e5e7eb;
  margin: 14px 0;
}

.text-center {
  text-align: center;
}

.muted {
  color: #9ca3af;
}

/* === Admin View Standalone Tab Styles === */
#adminView {
  padding: 10px 24px 0;
}

.view:not(.active) {
  display: none !important;
}

.admin-panel-shell {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  margin-top: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

/* === Admin View & Metric Cards Styles === */

.admin-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.admin-metric-card {
  background: white;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.admin-metric-card .metric-icon {
  font-size: 24px;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-metric-card div b {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.admin-metric-card div small {
  font-size: 11px;
  color: #64748b;
}

.admin-metric-card.warning .metric-icon {
  background: #fef3c7;
  color: #d97706;
}

.admin-metric-card.primary .metric-icon {
  background: #dbeafe;
  color: #2563eb;
}

.admin-panel-shell {
  background: white;
  border: 1px solid var(--line, #e2e8f0);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* === Profile View Styles === */
.user-only.hidden {
  display: none !important;
}

.profile-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 24px;
  margin-top: 20px;
}

.profile-panel {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.profile-info-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f3f4f6;
}

.info-row span {
  color: #6b7280;
  font-size: 13px;
}

.info-row strong {
  font-size: 14px;
  color: #111827;
}

/* === Hide Hidden and Empty Error/Success Message Boxes === */
.hidden,
.auth-error-msg:empty,
.auth-success-msg:empty,
.auth-error-msg.hidden,
.auth-success-msg.hidden {
  display: none !important;
}

/* === Agent Ops Command Center (Agent 部門指揮所) === */
.agent-section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.btn-agent-dept-toggle {
  background: #fbfbf8;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 5px 14px;
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  margin-bottom: 2px;
}

.btn-agent-dept-toggle:hover {
  background: #f0f4ef;
  color: var(--green);
  border-color: #b5c4bd;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(33, 74, 64, 0.08);
}

.agent-dept-drawer {
  flex-shrink: 0;
  max-height: 320px;
  overflow-y: auto;
  padding: 4px 4px 6px 4px;
  margin-bottom: 6px;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.agent-dept-drawer.collapsed {
  display: none !important;
}

/* 工作台漸進式備課導引條 (Borderless / Frameless) */
.workspace-stepper-ribbon {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  gap: 12px;
  flex-wrap: wrap;
}

.workspace-stepper-ribbon .stepper-step {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 160px;
  opacity: .45;
  transition: opacity 0.2s ease;
}

.workspace-stepper-ribbon .stepper-step.active,
.workspace-stepper-ribbon .stepper-step.done {
  opacity: 1;
}

.workspace-stepper-ribbon .stepper-num {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid #aeb5b1;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  flex-shrink: 0;
}

.workspace-stepper-ribbon .stepper-step.done .stepper-num {
  background: var(--green);
  color: #ffffff;
  border-color: var(--green);
}

.workspace-stepper-ribbon .stepper-step.active .stepper-num {
  background: var(--accent);
  color: #ffffff;
  border-color: var(--accent);
}

.workspace-stepper-ribbon .stepper-body {
  display: flex;
  flex-direction: column;
}

.workspace-stepper-ribbon .stepper-body b {
  font-size: 12px;
  color: var(--ink);
  font-weight: 600;
  line-height: 1.25;
}

.workspace-stepper-ribbon .stepper-body small {
  font-size: 10px;
  color: #74807b;
  margin-top: 1px;
}

.workspace-stepper-ribbon .stepper-arrow {
  color: #b5c0bb;
  font-size: 11px;
  flex-shrink: 0;
  user-select: none;
}

/* 帳號設定頂部資訊列 (Borderless / Frameless) */
.profile-top-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  gap: 12px;
}

.profile-toolbar-left,
.profile-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-toolbar-badge {
  font-size: 12px;
  font-weight: 700;
  color: var(--green);
  background: #eef4f1;
  padding: 3px 10px;
  border-radius: 99px;
  border: 1px solid #c9ded6;
}

.profile-toolbar-role {
  font-size: 12px;
  color: #56615c;
  font-weight: 500;
}

.profile-toolbar-quota {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

/* 管理員控制台頂部資訊列 (Borderless / Frameless, Unified single row) */
.admin-top-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-toolbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-toolbar-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  background: #eef4f1;
  padding: 4px 12px;
  border-radius: 99px;
  border: 1px solid #c9ded6;
}

.admin-metric-chips {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-metric-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: #56615c;
  background: #f8faf9;
  border: 1px solid #e2e8f0;
  border-radius: 99px;
  padding: 3px 10px;
  font-weight: 500;
}

.admin-metric-chip .chip-icon {
  font-size: 12.5px;
}

.admin-metric-chip .chip-label {
  color: #64748b;
  font-size: 11.5px;
}

.admin-metric-chip .chip-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
}

.admin-metric-chip.warning {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.admin-metric-chip.warning .chip-val {
  color: #b45309;
}

.admin-metric-chip.primary {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.admin-metric-chip.primary .chip-val {
  color: #2563eb;
}

#workspaceView .workspace-grid {
  margin-top: 0;
}

#deckView .preview-subtabs-bar {
  margin-top: 0;
}

#profileView .profile-cards-grid {
  margin-top: 0;
}

.agent-dept-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: #fbfbf8;
  border: 1px solid var(--line);
  border-radius: 10px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(33, 74, 64, 0.03);
  flex-wrap: wrap;
  gap: 10px;
}

.agent-dept-bar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.agent-dept-bar-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 99px;
  background: #eef4f1;
  color: var(--green);
  border: 1px solid #c9ded6;
}

.agent-dept-bar-title {
  font-size: 13px;
  font-weight: 600;
  color: #3b4742;
}

.agent-toolbar-right {
  margin-left: auto;
}

.dept-switch-chip {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dept-switch-chip:hover {
  border-color: var(--green);
  color: var(--green);
  background: #f4f8f6;
}

.dept-switch-chip.active {
  background: rgba(33, 74, 64, 0.1);
  border-color: var(--green);
  color: var(--green);
  font-weight: 700;
}

.btn-dept-expand {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 99px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-dept-expand:hover {
  color: var(--ink);
  border-color: var(--ink);
}

.agent-dept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 0;
}

.agent-dept-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.03);
  transition: all 0.2s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.agent-dept-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(223, 91, 56, 0.1);
}

.agent-dept-card.dept-card-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(223, 91, 56, 0.2), 0 4px 12px rgba(223, 91, 56, 0.08);
}

.agent-dept-card[data-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.65;
}

/* Department Card Structure: Icon on left spanning Layer 1 (Title) & Layer 2 (Role + Badge); Layer 3 (Description) below */
.dept-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.dept-icon {
  font-size: 26px;
  line-height: 1;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: #f1f5f3;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1px solid #dce4e0;
}

.dept-card-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dept-title-row {
  display: flex;
  align-items: center;
}

.dept-title,
.dept-card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  line-height: 1.25;
}

.dept-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.dept-role {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  line-height: 1.2;
}

.dept-badge {
  margin-left: auto;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: rgba(33, 74, 64, 0.08);
  color: var(--green);
  white-space: nowrap;
}

/* Layer 3: Description */
.dept-desc {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
  line-height: 1.5;
}

.dept-skills-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.skill-tag, .skill-chip-btn {
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  background: var(--paper);
  border: 1px solid var(--line);
  padding: 4px 10px;
  border-radius: 9999px;
  color: var(--fg);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.skill-chip-btn:hover {
  background: #f1f5f9;
  border-color: var(--green);
  color: var(--green);
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.agent-pptx-btn {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px !important;
  padding: 4px 10px !important;
  border-radius: 6px !important;
  background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%) !important;
  color: #ffffff !important;
  font-weight: 600 !important;
  border: none !important;
  box-shadow: 0 2px 6px rgba(79, 70, 229, 0.25) !important;
  transition: all 0.2s ease !important;
  cursor: pointer !important;
}

.agent-pptx-btn:hover {
  transform: translateY(-1px) !important;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.35) !important;
  filter: brightness(1.08) !important;
}

.agent-pptx-btn:disabled {
  opacity: 0.6 !important;
  cursor: wait !important;
  transform: none !important;
}

/* Agent Output Markdown Rich Text Rendering */
.agent-output-content {
  font-size: 13px;
  line-height: 1.6;
  color: var(--ink);
  word-break: break-word;
}

.agent-output-content h1,
.agent-output-content h2,
.agent-output-content h3,
.agent-output-content h4,
.agent-output-content h5,
.agent-output-content h6 {
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
  margin-top: 12px;
  margin-bottom: 5px;
}

.agent-output-content h1 { font-size: 16px; border-bottom: 1.5px solid var(--line); padding-bottom: 3px; }
.agent-output-content h2 { font-size: 15px; border-bottom: 1px solid var(--line); padding-bottom: 2px; }
.agent-output-content h3 { font-size: 14px; color: var(--green); }
.agent-output-content h4 { font-size: 13px; }

.agent-output-content .agent-p {
  margin: 0 0 6px 0;
  line-height: 1.55;
}

.agent-output-content .agent-ul,
.agent-output-content .agent-ol {
  margin: 4px 0 10px 20px;
  padding: 0;
}

.agent-output-content .agent-ul li,
.agent-output-content .agent-ol li {
  margin-bottom: 3px;
  line-height: 1.6;
}

.agent-output-content blockquote {
  border-left: 3px solid var(--accent);
  background: rgba(223, 91, 56, 0.05);
  padding: 6px 12px;
  border-radius: 4px;
  margin: 8px 0;
  color: #4b5563;
}

.agent-output-content .agent-inline-code {
  background: #f1f5f9;
  color: #0f172a;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: "Intel One Mono", monospace;
  font-size: 12.5px;
  border: 1px solid #e2e8f0;
}

.agent-output-content .agent-code-block {
  background: #1e293b;
  color: #f8fafc;
  border-radius: 8px;
  padding: 0;
  margin: 10px 0;
  overflow: hidden;
  font-family: "Intel One Mono", monospace;
  font-size: 12.5px;
}

.agent-output-content .agent-code-header {
  background: #0f172a;
  padding: 4px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  color: #94a3b8;
}

.agent-output-content .agent-code-copy-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #f8fafc;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
}

.agent-output-content .agent-code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.agent-output-content .agent-code-block code {
  display: block;
  padding: 10px 12px;
  overflow-x: auto;
  color: #e2e8f0;
}

.agent-output-content .agent-table-wrapper {
  overflow-x: auto;
  margin: 10px 0;
  border-radius: 6px;
  border: 1px solid var(--line);
}

.agent-output-content .agent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.agent-output-content .agent-table th,
.agent-output-content .agent-table td {
  padding: 6px 10px;
  border: 1px solid var(--line);
  text-align: left;
}

.agent-output-content .agent-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--ink);
}

.agent-output-content hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 12px 0;
}

.agent-msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
}

.agent-dept-chip {
  background: rgba(33, 74, 64, 0.1);
  color: var(--green);
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.agent-skill-chip {
  background: rgba(223, 91, 56, 0.1);
  color: var(--accent-dark);
  font-family: "Intel One Mono", monospace;
  padding: 2px 8px;
  border-radius: 6px;
}

.agent-sug-btn {
  border: 1px solid #d7dad4;
  background: #fff;
  padding: 7px 12px;
  border-radius: 20px;
  font-size: 11px;
  color: var(--ink);
  cursor: pointer;
  transition: all 0.15s ease;
}

.agent-sug-btn:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.agent-copy-btn {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.agent-copy-btn:hover {
  border-color: var(--green);
  color: var(--green);
}

/* === Mobile Responsive Enhancements (備課助手 & 管理員控制台 手機版體驗最佳化) === */

@media (max-width: 768px) {
  /* AI 備課助手 Mobile Layout */
  #agentView {
    padding: 16px 12px !important;
  }

  .agent-dept-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
  }

  .agent-dept-card {
    padding: 14px 12px !important;
    border-radius: 12px !important;
  }

  .dept-card-top,
  .dept-head-row,
  .dept-card-head {
    gap: 8px !important;
    margin-bottom: 6px !important;
  }

  .dept-icon {
    font-size: 20px !important;
    width: 36px !important;
    height: 36px !important;
  }

  .dept-title,
  .dept-card-head h3 {
    font-size: 13.5px !important;
  }

  .dept-role {
    font-size: 11px !important;
  }

  .dept-desc {
    font-size: 11.5px !important;
    margin-bottom: 6px !important;
    line-height: 1.35 !important;
  }

  .dept-chat-btn {
    min-height: 40px !important;
    font-size: 12px !important;
    padding: 8px 10px !important;
  }

  .agent-chat-shell {
    height: 58vh !important;
    min-height: 380px !important;
    border-radius: 12px !important;
  }

  /* Form Inputs iOS Auto-zoom Prevention (Font size >= 16px) */
  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    font-size: 16px !important;
  }

  #agentQueryInput, #questionInput {
    font-size: 16px !important; /* Prevents mobile Safari auto-zoom */
    min-height: 44px !important;
  }

  .agent-sug-btn, .skill-chip-btn {
    min-height: 36px !important;
    padding: 6px 10px !important;
    font-size: 11px !important;
  }

  /* 管理員控制台 Mobile Layout */
  #adminView {
    padding: 16px 12px !important;
  }

  .admin-metrics-grid {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
    margin-bottom: 16px !important;
  }

  .admin-panel-shell {
    padding: 14px 10px !important;
    border-radius: 10px !important;
  }

  .admin-table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    margin: 0 -6px !important;
    padding: 0 6px !important;
  }

  .admin-table th, .admin-table td {
    padding: 8px 6px !important;
    font-size: 11px !important;
  }

  .admin-table .btn-sm {
    min-height: 32px !important;
    padding: 4px 8px !important;
    font-size: 11px !important;
  }
}

@media (max-width: 480px) {
  .agent-dept-grid {
    grid-template-columns: 1fr !important;
  }
}

/* === Admin User Cards (Mobile Friendly Vertical Cards) === */
.admin-user-cards-wrapper {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.admin-user-card {
  background: var(--paper, #f9fafb);
  border: 1px solid var(--line, #e5e7eb);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.user-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line, #f3f4f6);
}

.user-card-header .username {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.user-card-header .user-id {
  font-size: 11px;
  color: var(--muted);
  margin-left: 4px;
}

.user-card-header .badges {
  display: flex;
  gap: 6px;
  align-items: center;
}

.user-card-body {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 14px;
  font-size: 12px;
}

.user-card-body .info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.user-card-body .info-item .lbl {
  font-size: 10.5px;
  color: var(--muted);
  font-weight: 600;
}

.user-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px dashed var(--line, #e5e7eb);
}

@media (max-width: 850px) {
  .admin-table-wrapper {
    display: none !important;
  }
  .admin-user-cards-wrapper {
    display: flex !important;
  }
}

/* 3合1 同頁面平行生成卡片矩陣 (Workspace Modules Matrix) */
.common-settings-card,
.module-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 1px 4px rgba(33, 74, 64, 0.03);
  transition: all 0.2s ease;
}

.common-settings-card {
  margin-top: 14px;
  margin-bottom: 18px;
}

.common-settings-card:hover,
.module-card:hover {
  border-color: #c4cdc8;
  box-shadow: 0 4px 12px rgba(33, 74, 64, 0.06);
}

.common-settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 12px;
}

.common-settings-title-group {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  row-gap: 2px;
  align-items: center;
}

.common-badge {
  grid-column: 1;
  grid-row: 1;
  background: #eff5f2;
  color: #1b4b3f;
  border: 1px solid #c9ded3;
  align-self: center;
}

.common-settings-title {
  grid-column: 2;
  grid-row: 1;
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.common-settings-subtitle {
  grid-column: 2;
  grid-row: 2;
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.35;
}

@media (max-width: 850px) {
  .btn-generate-all {
    width: 100%;
  }
}

.common-settings-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (max-width: 950px) {
  .common-settings-form-grid {
    grid-template-columns: 1fr;
  }
}

.btn-generate-all {
  padding: 11px 22px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, var(--accent) 0%, #bd4125 45%, var(--green) 100%);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 12px rgba(222, 91, 55, 0.25);
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  letter-spacing: 0.2px;
}

.btn-generate-all:hover:not(:disabled) {
  opacity: 0.96;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(222, 91, 55, 0.35);
}

.btn-generate-all:active:not(:disabled) {
  transform: translateY(0);
}

.btn-generate-all:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.8);
  transform: none;
  box-shadow: none;
}

.workspace-modules-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

@media (max-width: 950px) {
  .workspace-modules-grid {
    grid-template-columns: 1fr;
  }
}

.module-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.handout-module-card {
  border-top: 3.5px solid var(--accent);
  background: #fdfbfb;
}

.deck-module-card {
  border-top: 3.5px solid var(--green);
  background: #fbfdfc;
}

.quiz-module-card {
  border-top: 3.5px solid #3b5c78;
  background: #fafbfd;
}

.module-card-header {
  margin-bottom: 12px;
}

.module-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.module-title-wrap h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
}

.module-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}

.handout-badge {
  background: #fff2ed;
  color: #c85332;
  border: 1px solid #fbd2c4;
}

.deck-badge {
  background: #e6f4ee;
  color: #1a4a3e;
  border: 1px solid #b7dfd0;
}

.quiz-badge {
  background: #eef4f9;
  color: #2b4f6e;
  border: 1px solid #c9dbe8;
}

.module-desc {
  font-size: 12px;
  color: var(--muted);
  display: block;
  line-height: 1.4;
}

.module-form-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 18px;
}

.common-settings-form-grid label,
.module-form-body label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 500;
  color: #4b5752;
}

.common-settings-form-grid select,
.module-form-body select {
  width: 100%;
  padding: 8px 28px 8px 10px;
  font-size: 13px;
  font-weight: 400;
  font-family: var(--font), inherit;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12'%3E%3Cpath d='m3 5 3 3 3-3' fill='none' stroke='%23666'/%3E%3C/svg%3E") no-repeat right 10px center;
  appearance: none;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.common-settings-form-grid select option,
.module-form-body select option {
  font-weight: 400;
  color: var(--ink);
}

.common-settings-form-grid select:focus,
.module-form-body select:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 2px rgba(33, 74, 64, 0.1);
}

.common-settings-form-grid select:hover,
.module-form-body select:hover {
  border-color: #adb5b0;
}

.module-form-body .checkbox-label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 400;
  color: #4b5752;
  cursor: pointer;
  margin-top: 2px;
}

.module-form-body .checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--green);
  cursor: pointer;
  margin: 0;
  flex-shrink: 0;
}

.module-card-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.module-action-btn {
  width: 100%;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #fff;
}

.module-action-btn.handout-btn {
  background: linear-gradient(135deg, #df5b38 0%, #c84e2d 100%);
  box-shadow: 0 2px 6px rgba(223, 91, 56, 0.2);
}

.module-action-btn.handout-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #c84e2d 0%, #b23f20 100%);
  box-shadow: 0 4px 12px rgba(223, 91, 56, 0.3);
}

.module-action-btn.deck-btn {
  background: linear-gradient(135deg, #1f4e42 0%, #2b6758 100%);
  box-shadow: 0 2px 6px rgba(31, 78, 66, 0.2);
}

.module-action-btn.deck-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #173b32 0%, #215145 100%);
  box-shadow: 0 4px 12px rgba(31, 78, 66, 0.3);
}

.module-action-btn.quiz-btn {
  background: linear-gradient(135deg, #3b5c78 0%, #2c475e 100%);
  box-shadow: 0 2px 6px rgba(59, 92, 120, 0.2);
}

.module-action-btn.quiz-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #2c475e 0%, #1f3446 100%);
  box-shadow: 0 4px 12px rgba(59, 92, 120, 0.3);
}

.module-action-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.8);
}

.module-status-chip {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 6px;
  display: none;
  align-items: center;
  justify-content: space-between;
}

.module-status-chip.success {
  display: flex;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.module-status-chip.running {
  display: flex;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

.module-status-chip.error {
  display: flex;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.btn-inline-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Handout & Quiz Modal Content Styling */
.handout-modal-body .handout-sec {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.handout-modal-body .handout-sec h3 {
  margin-top: 0;
  color: #1e3a8a;
  font-size: 16px;
  margin-bottom: 8px;
}

.handout-modal-body .handout-sec ul,
.handout-modal-body .handout-sec ol {
  margin: 6px 0;
  padding-left: 20px;
}

.quiz-modal-body .quiz-item {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.quiz-modal-body .quiz-item h4 {
  margin: 0 0 8px 0;
  color: #065f46;
  font-size: 15px;
}

.quiz-modal-body .quiz-item .options-list {
  list-style-type: none;
  padding-left: 0;
  margin: 8px 0;
}

.quiz-modal-body .quiz-item .options-list li {
  padding: 6px 10px;
  background: #ffffff;
  border: 1px solid #d1fae5;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13.5px;
}

.quiz-modal-body .quiz-item .ans-box {
  background: #ecfdf5;
  border-left: 4px solid #059669;
  padding: 8px 12px;
  margin-top: 10px;
  font-size: 13px;
}

/* === 產出預覽中心 (Outputs & Preview Center) 樣式 === */
.preview-subtabs-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.preview-tabs {
  display: inline-flex;
  background: #ecefe8;
  border: 1px solid #dce1d9;
  border-radius: 99px;
  padding: 3px;
  gap: 3px;
  flex-shrink: 0;
}

.preview-tab-btn {
  border: none;
  background: transparent;
  color: #555e59;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 99px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.preview-tab-btn:hover {
  color: var(--green);
}

.preview-tab-btn.active {
  background: #ffffff;
  color: var(--green);
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.preview-content-panel {
  width: 100%;
}

/* 自然舒適之 A4 講義多色塊排版系統 */
.preview-handout-layout {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 32px 36px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.04);
  max-width: 900px;
  margin: 0 auto;
}

.handout-header-block {
  margin-bottom: 24px;
  padding-bottom: 14px;
  border-bottom: 2px solid #2563eb;
}

.handout-header-block h2 {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  margin: 0 0 6px 0;
  line-height: 1.35;
}

.handout-header-block p {
  margin: 0;
  color: #64748b;
  font-size: 13.5px;
  line-height: 1.5;
}

.handout-overview-box {
  margin: 20px 0;
  padding: 12px 16px;
  background: #eff6ff;
  border-left: 4px solid #2563eb;
  border-radius: 0 6px 6px 0;
  color: #1e3a8a;
  font-size: 13.5px;
  line-height: 1.6;
}

.handout-overview-box b {
  color: #1e40af;
  font-size: 14px;
}

.handout-section-card {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px dashed #e2e8f0;
}

.handout-section-card:last-of-type {
  border-bottom: none;
}

.handout-section-card h3 {
  font-size: 16.5px;
  font-weight: 700;
  color: #1e3a8a;
  margin: 0 0 10px 0;
}

.handout-section-card p.sec-summary {
  margin: 0 0 12px 0;
  color: #334155;
  font-size: 14px;
  line-height: 1.65;
}

.handout-key-points-box {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 6px;
  padding: 12px 16px;
  color: #166534;
  font-size: 13px;
  margin: 12px 0;
}

.handout-key-points-box b {
  color: #166534;
  font-size: 13.5px;
}

.handout-key-points-box ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.handout-key-points-box li {
  margin-bottom: 4px;
  line-height: 1.6;
}

.handout-questions-box {
  background: #fffbeb;
  border: 1px solid #fef3c7;
  border-radius: 6px;
  padding: 12px 16px;
  color: #92400e;
  font-size: 13px;
  margin: 12px 0;
}

.handout-questions-box b {
  color: #92400e;
  font-size: 13.5px;
}

.handout-questions-box ol, .handout-questions-box ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.handout-questions-box li {
  margin-bottom: 6px;
  line-height: 1.6;
}

.handout-source-pages {
  display: block;
  font-size: 11.5px;
  color: #94a3b8;
  text-align: right;
  margin-top: 8px;
}

.handout-takeaways-box {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  padding: 16px 20px;
  margin-top: 24px;
  color: #0f172a;
}

.handout-takeaways-box b {
  font-size: 14.5px;
  color: #0f172a;
  display: block;
  margin-bottom: 8px;
}

.handout-takeaways-box ul {
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  line-height: 1.6;
}

.preview-quiz-layout {
  max-width: 900px;
  margin: 0 auto;
}

.quiz-question-card {
  margin-bottom: 18px;
  padding: 16px;
  background: #ffffff;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #2563eb;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.quiz-question-card h4 {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
  flex: 1;
}

.quiz-diff-chip {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 99px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #cbd5e1;
  font-weight: 600;
  white-space: nowrap;
}

.quiz-option-item {
  font-size: 13.5px;
  color: #1e293b;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.quiz-option-item:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.preview-quiz-ans-block {
  margin-top: 10px;
  padding: 12px 14px;
  background: #f0fdf4;
  border-radius: 6px;
  border: 1px solid #bbf7d0;
  border-left: 4px solid #16a34a;
  font-size: 13px;
  color: #166534;
}

.preview-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
  background: #fafaf7;
  border: 1.5px dashed #d5d8ce;
  border-radius: 8px;
  text-align: center;
}

.preview-empty-state span {
  font-size: 32px;
  margin-bottom: 12px;
  opacity: 0.8;
}

.preview-empty-state b {
  font-size: 15px;
  color: var(--green);
  margin-bottom: 6px;
}

.preview-empty-state small {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
}

/* === Inline Manual Editing & AI Micro-Refinement Styles === */

.btn-micro-refine {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-micro-refine:hover:not(:disabled) {
  background: #dcfce7;
  border-color: #86efac;
  color: #14532d;
  box-shadow: 0 2px 6px rgba(16, 185, 129, 0.2);
  transform: translateY(-1px);
}

.btn-micro-refine:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-regen-question {
  background: #f0f4f8;
  color: #2c4a63;
  border: 1px solid #cbd5e1;
  border-radius: 99px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.btn-regen-question:hover:not(:disabled) {
  background: #e2e8f0;
  color: #1e293b;
  border-color: #94a3b8;
  box-shadow: 0 2px 6px rgba(59, 92, 120, 0.12);
}

.btn-regen-question:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.edit-sync-indicator {
  font-size: 11px;
  color: #64748b;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s ease;
}

.edit-sync-indicator.saving {
  color: #d97706;
}

.edit-sync-indicator.saved {
  color: #059669;
  font-weight: 600;
}

/* Contenteditable Subtle Visual Affordance */
[contenteditable="true"] {
  outline: none;
  border-radius: 4px;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  cursor: text;
}

[contenteditable="true"]:hover {
  background-color: rgba(37, 99, 235, 0.03);
}

[contenteditable="true"]:focus {
  background-color: #ffffff;
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.35);
}

.notes-editor-container {
  position: relative;
}

.notes-editor-container p[contenteditable="true"] {
  min-height: 54px;
  padding: 8px 10px;
  border: 1px dashed transparent;
}

.notes-editor-container p[contenteditable="true"]:hover {
  border-color: #cbd5e1;
}

.notes-editor-container p[contenteditable="true"]:focus {
  border-color: #10b981;
}

/* === Application Footer Styles === */

.app-footer {
  margin-top: 36px;
  padding: 20px 32px 28px;
  border-top: 1px solid var(--line);
  background: transparent;
  width: 100%;
  box-sizing: border-box;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-logo {
  font-size: 13px;
  font-weight: 700;
  color: var(--green);
  letter-spacing: -0.01em;
}

.footer-copy {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.footer-link-btn {
  background: none;
  border: none;
  padding: 0;
  color: #64748b;
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-link-btn:hover {
  color: var(--green);
  text-decoration: underline;
}

.footer-sep {
  color: #cbd5e1;
  font-size: 11px;
}

@media(max-width: 768px) {
  .app-footer {
    padding: 20px 16px 28px;
    margin-top: 32px;
  }
  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
}

/* === Demo Sample Loader & Editable Affordance Styles === */

.demo-sample-wrapper {
  margin-top: 14px;
  padding: 10px 12px;
  background: #fbfbf8;
  border: 1px dashed var(--line);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.demo-sample-text {
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.45;
  display: block;
}

.demo-sample-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.btn-demo-sample {
  background: #f4f7f4;
  color: var(--green);
  border: 1px solid #c8d9cf;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: center;
  width: 100%;
}

.btn-demo-sample.btn-goto-agent {
  background: #fff8f5;
  color: var(--accent);
  border-color: #fbd9cf;
}

.btn-demo-sample:hover {
  background: #e6efe8;
  border-color: var(--green);
  box-shadow: 0 2px 6px rgba(33, 74, 64, 0.12);
  transform: translateY(-1px);
}

.btn-demo-sample.btn-goto-agent:hover {
  background: #ffede6;
  border-color: var(--accent);
  box-shadow: 0 2px 6px rgba(223, 91, 56, 0.15);
}

.btn-demo-sample:active {
  transform: translateY(0);
}

.editable-hint-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  margin-bottom: 18px;
  background: #f8faf7;
  border: 1px solid #e1e8df;
  border-radius: 8px;
  font-size: var(--fs-xs);
  color: #4a5c54;
}

.editable-hint-banner b {
  color: var(--green);
  font-weight: 700;
}

.editable-hint-banner span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* === Legal In-App Views (Terms & Privacy) === */
.legal-view-container {
  max-width: 820px;
  margin: 0 auto;
  padding: 4px 14px 0;
  animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.legal-view-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.legal-card,
.legal-view-card {
  background: var(--card, #ffffff);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px 28px;
  box-shadow: var(--shadow);
}

.legal-title-section,
.legal-header-block {
  border-bottom: 1.5px solid var(--line);
  padding-bottom: 12px;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.legal-title-section h1,
.legal-title-section h2,
.legal-header-block h1,
.legal-header-block h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
  margin: 0;
  letter-spacing: -0.01em;
}

.legal-title-section p,
.legal-header-block p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.legal-content,
.legal-body-text {
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.legal-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.legal-section h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--green);
  margin: 0 0 2px 0;
}

.legal-section p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
  color: var(--ink);
}

.legal-section p + p {
  margin-top: 6px;
}

.legal-table-box,
.legal-table-wrapper {
  margin: 8px 0 0;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.legal-table,
.legal-data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  text-align: left;
}

.legal-table th,
.legal-data-table th {
  background: rgba(16, 185, 129, 0.06);
  border-bottom: 1px solid var(--line);
  padding: 7px 12px;
  font-weight: 700;
  color: var(--green);
  font-size: 12px;
}

.legal-table td,
.legal-data-table td {
  padding: 7px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}

.legal-table tr:last-child td,
.legal-data-table tr:last-child td {
  border-bottom: none;
}

@media (max-width: 768px) {
  .legal-card,
  .legal-view-card {
    padding: 18px 16px;
  }
}

/* === 全域列印與另存 A4 PDF 樣式 (Global Print Styles) === */
@media print {
  *, *:before, *:after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* 隱藏無關之導航列、側邊欄、彈窗與操作按鈕 */
  .grain,
  .sidebar,
  .sidebar-overlay,
  .topbar,
  .topbar-restore-pill,
  .auth-modal,
  .custom-toast,
  .preview-tabs-nav,
  .preview-tab-pane:not(.active),
  .preview-tab-pane.hidden,
  .secondary-button,
  .primary-button,
  .btn,
  .btn-regen-question,
  .editable-hint-banner,
  .no-print,
  #loadSampleBtn,
  #removeFile {
    display: none !important;
  }

  html,
  body {
    background: #ffffff !important;
    color: #111827 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
  }

  .app-layout,
  .main-content,
  .view,
  .preview-container,
  .preview-tab-pane.active {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
    position: static !important;
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
  }

  #previewView {
    display: block !important;
  }

  .handout-section-card,
  .quiz-question-card,
  .slide-stage-card {
    box-shadow: none !important;
    border: 1px solid #e2e8f0 !important;
    page-break-inside: avoid !important;
    break-inside: avoid !important;
    margin-bottom: 16px !important;
  }
}