:root {
  color-scheme: light;
  font-family: "Noto Sans TC", "Microsoft JhengHei", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #1f2933;
  background: #eef2f4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #eef2f4;
}

button,
textarea,
select {
  font: inherit;
}

.page-shell {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
  padding: 26px 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 1.12rem;
}

h3 {
  margin-bottom: 10px;
  font-size: 1rem;
}

dt {
  color: #5b6770;
  font-size: 0.78rem;
}

dd {
  margin: 3px 0 0;
  font-weight: 700;
  color: #111827;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.75fr);
  gap: 24px;
  align-items: start;
}

.map-panel,
.assistant-panel {
  background: #ffffff;
  border: 1px solid #d7dee2;
  border-radius: 8px;
  padding: 18px;
}

.assistant-panel.ai-helper {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  min-height: 790px;
  padding: 0;
  overflow: hidden;
  border-color: #d5e3ee;
  background: #f8fbfd;
}

.helper-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
  padding: 18px 16px 14px;
  background: #ffffff;
  border-bottom: 1px solid #dce8f1;
}

.helper-title-group {
  display: flex;
  gap: 12px;
  align-items: center;
}

.helper-avatar {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 800;
  background: linear-gradient(135deg, #1976d2, #6c5ce7);
  border-radius: 12px;
  box-shadow: 0 8px 18px rgba(25, 118, 210, 0.28);
}

.helper-title-line {
  display: flex;
  gap: 8px;
  align-items: center;
}

.helper-title-line h2 {
  color: #0b65b9;
  font-size: 1.22rem;
}

.beta-badge {
  padding: 2px 6px;
  color: #ffffff;
  font-size: 0.66rem;
  font-weight: 800;
  background: #4b9ce2;
  border-radius: 8px;
}

.helper-header p {
  margin: 2px 0 0;
  color: #738596;
  font-size: 0.82rem;
}

.helper-icons {
  display: flex;
  gap: 8px;
}

.helper-icons button {
  display: grid;
  place-items: center;
  width: 30px;
  min-height: 30px;
  color: #34495e;
  background: transparent;
  border-radius: 50%;
  font-size: 1.05rem;
}

.response-mode {
  padding: 10px 12px;
  background: #f3f8fc;
  border-bottom: 1px solid #dce8f1;
}

.response-mode > span {
  display: block;
  margin-bottom: 8px;
  color: #5f7388;
  font-size: 0.78rem;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  background: #ffffff;
  border: 1px solid #c8dbea;
  border-radius: 10px;
}

.mode-toggle button {
  display: grid;
  gap: 2px;
  min-height: 48px;
  color: #31465a;
  background: transparent;
  border-radius: 8px;
  line-height: 1.25;
}

.mode-toggle button.is-active {
  color: #0b65b9;
  background: #e7f4ff;
  border: 1px solid #b8dcf8;
}

.mode-toggle small {
  color: inherit;
  font-size: 0.72rem;
  font-weight: 500;
}

.helper-body {
  min-height: 0;
  padding: 14px 12px;
  overflow-y: auto;
}

.assistant-view[hidden] {
  display: none;
}

.context-card,
.progress-card,
.result-card,
.action-card {
  border: 1px solid #bfe0f6;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(42, 92, 130, 0.08);
}

.context-card {
  padding: 14px;
  margin-bottom: 14px;
}

.card-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #0b65b9;
  font-size: 0.78rem;
  font-weight: 800;
}

.card-topline button {
  min-height: auto;
  padding: 0;
  color: #0b65b9;
  background: transparent;
  font-size: 0.78rem;
}

.context-card h3 {
  margin: 4px 0 12px;
  color: #203345;
  font-size: 1.12rem;
}

.context-summary {
  display: grid;
  gap: 9px;
  margin: 0;
  padding-bottom: 12px;
  border-bottom: 1px dashed #cbddeb;
}

.context-summary div {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 10px;
}

.context-summary dt {
  color: #688094;
  font-size: 0.84rem;
}

.context-summary dd {
  color: #203345;
  font-size: 0.88rem;
}

.context-ready {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding-top: 10px;
  color: #6f8395;
  font-size: 0.76rem;
}

.context-ready span {
  width: 10px;
  height: 10px;
  background: #2ec58f;
  border-radius: 50%;
}

.action-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 74px;
  margin-bottom: 12px;
  padding: 12px 14px;
  cursor: pointer;
}

.action-card:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
}

.action-card h3 {
  margin: 0 0 4px;
  color: #203345;
  font-size: 0.98rem;
}

.action-card p {
  margin: 0;
  color: #7a8d9e;
  font-size: 0.78rem;
}

.action-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  font-weight: 800;
}

.primary-action .action-icon {
  color: #0b65b9;
  background: #e7f4ff;
}

.view-label {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
  color: #0b65b9;
  font-size: 0.78rem;
  font-weight: 800;
}

.view-label button {
  width: 28px;
  min-height: 28px;
  color: #34495e;
  background: transparent;
  font-size: 1.4rem;
}

.view-label small {
  color: #8a9baa;
  font-weight: 500;
}

.progress-card {
  padding: 16px;
}

.progress-title {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
}

.progress-title h3 {
  margin: 0;
  color: #203345;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid #d8ecfb;
  border-top-color: #1e88e5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.progress-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 20px;
  color: #138d75;
  font-size: 0.84rem;
}

.progress-list .is-active {
  color: #0b65b9;
  font-weight: 800;
}

.result-card {
  overflow: hidden;
}

.result-heading {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 16px 16px 8px;
}

.result-heading h3 {
  margin: 0;
  color: #203345;
  font-size: 1.08rem;
}

.result-heading span {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: #047857;
  background: #dcfce7;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
}

.answer-content {
  padding: 0 16px 16px;
  color: #34495e;
  line-height: 1.75;
}

.answer-status {
  margin: 0 16px 16px;
  padding: 10px 12px;
  color: #6f8395;
  background: #fbfdff;
  border: 1px solid #dce8f1;
  border-radius: 8px;
  font-size: 0.78rem;
}

.followups {
  margin-top: 14px;
}

.followups p {
  margin-bottom: 8px;
  color: #6f8395;
  font-size: 0.82rem;
}

.followups button {
  display: block;
  width: fit-content;
  max-width: 100%;
  min-height: 32px;
  margin: 0 0 8px;
  padding: 6px 10px;
  color: #0b65b9;
  background: #ffffff;
  border: 1px solid #bfe0f6;
  border-radius: 999px;
  font-size: 0.78rem;
  text-align: left;
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  padding: 10px 10px 6px;
  background: #ffffff;
  border-top: 1px solid #dce8f1;
}

.chat-composer select {
  grid-column: 1 / -1;
  min-height: 38px;
  padding: 8px 10px;
}

.chat-composer textarea {
  min-height: 44px;
  max-height: 110px;
  resize: vertical;
  border-radius: 10px;
}

.chat-composer button {
  min-height: 44px;
  color: #ffffff;
  background: #b8c9d7;
  border-radius: 12px;
  font-size: 1.25rem;
}

.helper-disclaimer {
  margin: 0;
  padding: 0 12px 10px;
  color: #f97316;
  background: #ffffff;
  font-size: 0.7rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.panel-heading span {
  color: #64727c;
  font-size: 0.86rem;
}

.map-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid #d7dee2;
}

.map-tab {
  min-height: 38px;
  padding: 0 16px;
  color: #52616b;
  background: transparent;
  border-radius: 8px 8px 0 0;
  border-bottom: 3px solid transparent;
}

.map-tab.is-active {
  color: #0f766e;
  background: #eef8f7;
  border-bottom-color: #0f766e;
}

.upload-panel {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
  padding: 14px;
  background: #f7f9fa;
  border: 1px solid #d7dee2;
  border-radius: 8px;
}

.upload-row,
.map-library-row {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.map-library-row {
  grid-template-columns: auto minmax(180px, 1fr) auto;
}

.file-picker {
  display: inline-grid;
  place-items: center;
  min-height: 42px;
  padding: 0 16px;
  color: #0f4f4a;
  background: #dcefed;
  border-radius: 8px;
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-name,
.library-status {
  min-width: 0;
  color: #52616b;
  font-size: 0.9rem;
}

.secondary-button {
  padding: 0 16px;
  color: #0f4f4a;
  background: #dcefed;
}

.danger-button {
  padding: 0 16px;
  color: #ffffff;
  background: #b42318;
}

.map-tab-panel[hidden] {
  display: none;
}

.map-frame {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 520px;
  overflow: hidden;
  background: #f7f9fa;
  border: 1px solid #d7dee2;
  border-radius: 8px;
}

.map-frame img {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 680px;
  object-fit: contain;
}

.map-placeholder {
  display: grid;
  gap: 8px;
  text-align: center;
  color: #52616b;
  padding: 24px;
}

.map-placeholder[hidden],
.map-frame img[hidden] {
  display: none;
}

.map-placeholder strong {
  color: #1f2933;
}

.iframe-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  min-height: 40px;
  margin-bottom: 10px;
  color: #52616b;
  font-size: 0.9rem;
}

.iframe-toolbar a {
  color: #0f766e;
  font-weight: 700;
  text-decoration: none;
}

.iframe-toolbar a:hover {
  text-decoration: underline;
}

.dra-iframe {
  display: block;
  width: 100%;
  min-height: 700px;
  border: 1px solid #d7dee2;
  border-radius: 8px;
  background: #ffffff;
}

.iframe-warning {
  margin-top: 10px;
  padding: 12px 14px;
  color: #5f4b13;
  background: #fff7d6;
  border: 1px solid #ead487;
  border-radius: 8px;
  line-height: 1.6;
}

label {
  font-weight: 700;
}

textarea,
select {
  width: 100%;
  padding: 12px;
  color: #111827;
  background: #ffffff;
  border: 1px solid #b8c2c8;
  border-radius: 8px;
}

textarea {
  min-height: 128px;
  resize: vertical;
}

select {
  min-height: 42px;
}

textarea:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: #0f766e;
}

select:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: #0f766e;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.answer-content p {
  margin: 0 0 12px;
}

.answer-content p:last-child,
.answer-content ul:last-child {
  margin-bottom: 0;
}

.answer-content h4,
.answer-content h5,
.answer-content h6 {
  margin: 14px 0 8px;
  line-height: 1.35;
}

.answer-content h4:first-child,
.answer-content h5:first-child,
.answer-content h6:first-child {
  margin-top: 0;
}

.answer-content ul {
  margin: 0 0 12px;
  padding-left: 22px;
}

.answer-content li {
  margin: 4px 0;
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 28px, 720px);
    padding: 24px 0;
  }

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

  .map-frame {
    min-height: 360px;
  }

  .upload-row,
  .map-library-row {
    grid-template-columns: 1fr;
  }
}
