:root {
  color-scheme: dark;
  --bg: #17191b;
  --panel: #23272b;
  --panel-strong: #2c3237;
  --field: #111315;
  --line: #434b53;
  --muted: #aab3bb;
  --text: #f4f7f9;
  --accent: #d89b28;
  --accent-dark: #a76f14;
  --ok: #48a868;
  --danger: #df6b57;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, "Microsoft JhengHei", "Noto Sans TC", sans-serif;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 42px 42px;
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

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

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  padding: 0 0 18px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.16;
  letter-spacing: 0;
}

h2 {
  font-size: 20px;
  letter-spacing: 0;
}

h3 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 0;
}

.status-chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 6px;
  padding: 10px 14px;
  color: #d9e0e6;
  background: rgba(35, 39, 43, 0.88);
  font-size: 13px;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(360px, 1.18fr);
  gap: 18px;
  align-items: start;
}

.input-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(35, 39, 43, 0.96);
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 22px;
}

.section-heading {
  margin-bottom: 18px;
}

.section-heading p,
.result-header p,
.group-heading p {
  margin-top: 7px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.estimator-group {
  border: 1px solid #3d464e;
  border-radius: 8px;
  padding: 16px;
  background: rgba(24, 27, 30, 0.58);
}

.estimator-group + .estimator-group {
  margin-top: 16px;
}

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

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

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  color: #d4dbe1;
  font-size: 14px;
  line-height: 1.35;
}

input,
select {
  width: 100%;
  height: 44px;
  border: 1px solid #58616a;
  border-radius: 6px;
  padding: 0 12px;
  background: var(--field);
  color: var(--text);
  outline: none;
}

select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #d4dbe1 50%) calc(100% - 18px) 50% / 6px 6px no-repeat,
    linear-gradient(135deg, #d4dbe1 50%, transparent 50%) calc(100% - 12px) 50% / 6px 6px no-repeat,
    var(--field);
  padding-right: 34px;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(216, 155, 40, 0.16);
}

.toggle-row {
  flex: 0 0 auto;
  align-items: center;
  flex-direction: row;
  min-height: 36px;
  gap: 9px;
  border: 1px solid #4d565f;
  border-radius: 6px;
  padding: 0 10px;
  background: #171a1d;
  color: #eef3f6;
  font-weight: 700;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  accent-color: var(--accent);
}

.compact-grid {
  gap: 12px;
}

.weight-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
  border: 1px solid rgba(216, 155, 40, 0.42);
  border-radius: 8px;
  padding: 14px;
  background: #251f18;
}

.weight-preview span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.weight-preview strong {
  display: block;
  color: #ffd181;
  font-size: 28px;
  line-height: 1.1;
}

.primary-button,
.copy-button,
.secondary-button {
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  margin-top: 20px;
  background: var(--accent);
  color: #151515;
}

.primary-button:hover,
.copy-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.primary-button:hover {
  background: #e7ab38;
}

.result-panel {
  padding: 20px;
}

.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.copy-button {
  flex: 0 0 auto;
  min-height: 40px;
  border: 1px solid var(--line);
  padding: 0 14px;
  background: #16191c;
  color: var(--text);
}

.copy-button:hover {
  border-color: var(--accent);
}

.secondary-button {
  flex: 0 0 auto;
  min-height: 40px;
  border: 1px solid rgba(216, 155, 40, 0.72);
  padding: 0 14px;
  background: #171a1d;
  color: #ffd181;
}

.secondary-button:hover {
  background: #2d251a;
}

.copy-button.copied {
  border-color: var(--ok);
  color: #d9ffe5;
}

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

.result-card {
  min-height: 104px;
  border: 1px solid #3d464e;
  border-radius: 8px;
  padding: 16px;
  background: var(--panel-strong);
}

.result-card span {
  display: block;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.result-card strong {
  display: block;
  color: #ffffff;
  font-size: clamp(22px, 3.2vw, 30px);
  line-height: 1.15;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.highlight-card {
  grid-column: 1 / -1;
  border-color: rgba(216, 155, 40, 0.76);
  background: #332b1f;
}

.highlight-card strong {
  color: #ffd181;
}

.note {
  margin-top: 18px;
  border-left: 4px solid var(--accent);
  padding: 12px 14px;
  background: rgba(35, 39, 43, 0.82);
  color: #c9d1d8;
  font-size: 14px;
  line-height: 1.7;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  border: 1px solid rgba(72, 168, 104, 0.7);
  border-radius: 6px;
  padding: 12px 14px;
  background: #183623;
  color: #e2ffeb;
  box-shadow: var(--shadow);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

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

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

  .app-header,
  .result-header,
  .group-heading,
  .weight-preview {
    align-items: stretch;
    flex-direction: column;
  }

  .status-chip,
  .copy-button,
  .secondary-button {
    width: 100%;
    text-align: center;
  }

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

  .input-panel,
  .result-panel {
    padding: 16px;
  }
}
