:root {
  color-scheme: light;
  --ink: #18312f;
  --muted: #5f6f6b;
  --line: #d9e2df;
  --paper: #f7faf8;
  --panel: #ffffff;
  --green: #2f7d5f;
  --green-dark: #1f5f49;
  --amber: #a85d12;
  --red: #b53636;
  --blue: #2766a8;
  --shadow: 0 18px 50px rgba(31, 62, 55, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(180deg, rgba(47, 125, 95, 0.08), rgba(247, 250, 248, 0) 320px),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Noto Sans TC", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.workbench {
  display: grid;
  gap: 14px;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 24px;
  padding: 22px 24px;
  border: 1px solid rgba(217, 226, 223, 0.88);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 14px 42px rgba(31, 62, 55, 0.08);
}

.brand-hero {
  min-width: 0;
}

.brand-block {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.brand-mark-row {
  display: flex;
  align-items: end;
  gap: 18px;
}

.brand-logo {
  width: auto;
  height: clamp(98px, 11vw, 128px);
  margin-left: clamp(-36px, -3vw, -26px);
}

.masthead-mascot {
  width: auto;
  height: clamp(72px, 8vw, 94px);
  flex: 0 0 auto;
  filter: drop-shadow(0 10px 20px rgba(31, 62, 55, 0.12));
}

.masthead-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--green-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  letter-spacing: 0;
}

.domain-chip {
  display: grid;
  gap: 4px;
  min-width: 190px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
}

.icon-action {
  align-self: center;
  min-width: 76px;
}

.domain-chip span,
label span,
.panel-toolbar p {
  color: var(--muted);
  font-size: 0.84rem;
}

.domain-chip strong {
  color: var(--green-dark);
  font-size: 1.2rem;
}

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

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

.input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.tag-picker {
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
}

.tag-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 800;
}

.tag-picker-header p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.tag-library-tools {
  margin-bottom: 10px;
}

.tag-library-tools input {
  height: 38px;
  background: #fff;
}

.tag-category-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.tag-category {
  min-height: 34px;
  padding: 0 10px;
  border-color: var(--line);
  background: #fff;
  color: var(--muted);
  font-size: 0.84rem;
}

.tag-category.active {
  border-color: var(--green);
  background: rgba(47, 125, 95, 0.11);
  color: var(--green-dark);
}

.tag-category small {
  margin-left: 6px;
  color: inherit;
  font-size: 0.72rem;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 132px;
  overflow: auto;
  padding-right: 4px;
}

.tag-chip {
  min-height: 32px;
  padding: 0 10px;
  border-color: #cbd9d4;
  background: #f6faf8;
  color: var(--green-dark);
  font-size: 0.86rem;
}

.tag-chip.active {
  border-color: var(--green);
  background: rgba(47, 125, 95, 0.13);
}

.tag-chip small {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.74rem;
}

.tag-empty {
  width: 100%;
  padding: 10px 2px;
  color: var(--muted);
  font-size: 0.86rem;
}

.text-action {
  min-height: 30px;
  padding: 0 8px;
  border-color: var(--line);
  background: #fff;
  color: var(--green-dark);
  font-size: 0.82rem;
}

label {
  display: grid;
  gap: 8px;
  min-width: 0;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfc;
  color: var(--ink);
  outline: none;
}

input {
  height: 44px;
  padding: 0 12px;
}

textarea {
  min-height: 210px;
  margin-top: 14px;
  padding: 14px;
  resize: vertical;
  line-height: 1.55;
}

input:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(47, 125, 95, 0.14);
}

.file-button,
button,
.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

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

.primary {
  background: var(--green);
  color: #fff;
}

.primary:hover {
  background: var(--green-dark);
}

.secondary,
.file-button {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary:hover,
.file-button:hover {
  border-color: var(--green);
}

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

.actions,
.result-actions,
.import-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
}

.actions,
.result-actions {
  margin-top: 14px;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 22px;
}

.login-panel {
  width: min(100%, 430px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-brand {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.login-logo {
  width: min(100%, 230px);
  height: auto;
}

.login-mascot {
  width: 92px;
  height: auto;
  justify-self: end;
  filter: drop-shadow(0 10px 18px rgba(31, 62, 55, 0.12));
}

.login-panel h1 {
  margin-bottom: 22px;
  font-size: 2rem;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-message {
  min-height: 24px;
  color: var(--red);
  font-weight: 700;
}

.result-panel {
  min-height: 320px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
}

th,
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 0.92rem;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef5f1;
  color: var(--green-dark);
  font-size: 0.78rem;
  text-transform: uppercase;
}

td a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}

.empty {
  height: 160px;
  color: var(--muted);
  text-align: center;
  vertical-align: middle;
}

.status {
  display: inline-flex;
  align-items: center;
  min-width: 64px;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.status.ok {
  background: rgba(47, 125, 95, 0.12);
  color: var(--green-dark);
}

.status.error {
  background: rgba(181, 54, 54, 0.12);
  color: var(--red);
}

.status.pending {
  background: rgba(168, 93, 18, 0.12);
  color: var(--amber);
}

.truncate {
  max-width: 360px;
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding: 22px 0;
  }

  .masthead,
  .panel-toolbar,
  .input-grid {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .panel-toolbar {
    display: grid;
  }

  .masthead {
    padding: 18px;
  }

  .brand-logo {
    width: auto;
    height: 88px;
    margin-left: clamp(-32px, -8vw, -20px);
  }

  .masthead-mascot {
    display: block;
    height: 68px;
  }

  .domain-chip {
    min-width: 0;
  }

  .masthead-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions,
  .result-actions,
  .import-actions {
    justify-content: stretch;
  }

  .actions button,
  .result-actions button,
  .import-actions .button-link,
  .file-button {
    width: 100%;
  }
}
