
:root {
  --bg: #fffaf0;
  --bg-2: #fffdf7;
  --white: #ffffff;
  --ink: #1f2b43;
  --muted: #7b869b;
  --line: #e8e2d6;
  --line-2: #e8edf6;
  --yellow: #f8c43c;
  --yellow-deep: #f2a70c;
  --yellow-soft: #fff5cb;
  --blue: #5c8ef5;
  --blue-soft: #eef4ff;
  --pink: #ffb5c6;
  --green: #4cbf8d;
  --shadow: 0 18px 45px rgba(67, 50, 12, 0.08);
  --shadow-sm: 0 8px 22px rgba(67, 50, 12, 0.06);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #fffdf7 0%, #fff9ef 100%);
}

a { color: inherit; text-decoration: none; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.page-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at 12% 16%, rgba(255, 212, 96, 0.20), transparent 20%),
    radial-gradient(circle at 94% 10%, rgba(255, 186, 200, 0.12), transparent 18%),
    radial-gradient(circle at 90% 82%, rgba(119, 164, 255, 0.08), transparent 22%),
    radial-gradient(circle at 8% 78%, rgba(255, 223, 146, 0.12), transparent 20%);
}

.duplicate-container {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
}

/* 只放寬此工具頁的內容列；共用頁首與頁尾維持既有容器設定。 */
.duplicate-page .crumb-row {
  width: min(1440px, calc(100% - 32px));
}

.main-layout {
  padding: 18px 0 48px;
}

.breadcrumb-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: rgba(255,255,255,0.78);
  border: 1px solid rgba(236, 229, 217, 0.92);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  color: #6f7b90;
  margin-bottom: 16px;
}
.breadcrumb-card strong { color: var(--blue); }
.breadcrumb-card .tool-tag {
  margin-left: auto;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--yellow-soft);
  color: #946406;
  font-weight: 800;
}
.sep { opacity: 0.55; }

.hero-card {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: center;
  padding: 24px 30px;
  background: linear-gradient(180deg, #fffefb 0%, #fff8ee 100%);
  border: 1px solid #f0e6d6;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.hero-left, .hero-right { position: relative; }
.hero-mascot {
  width: 100%;
  max-width: 150px;
  object-fit: contain;
}
.hero-center h1 {
  margin: 0 0 10px;
  font-size: clamp(34px, 4vw, 58px);
  line-height: 1.05;
  letter-spacing: -1px;
}
.hero-kicker {
  display: inline-block;
  margin-bottom: 10px;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--yellow-soft);
  color: #926000;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .12em;
}
.hero-center p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.7;
}
.hero-points {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  padding: 0;
  margin: 0;
  list-style: none;
  color: #6b7388;
  font-weight: 700;
}
.hero-points li::before {
  content: '✦';
  color: var(--yellow-deep);
  margin-right: 8px;
}
.hero-illustration {
  width: 100%;
  object-fit: contain;
}
.mini-note {
  position: absolute;
  top: -8px;
  right: -10px;
  padding: 16px 18px;
  border-radius: 18px;
  background: #fff4cc;
  border: 2px solid #f1d17f;
  box-shadow: var(--shadow-sm);
  color: #7b5a08;
  font-weight: 800;
  line-height: 1.5;
  transform: rotate(8deg);
}

.tool-panel {
  position: relative;
  margin-top: 18px;
  padding: 26px 26px 112px;
  background:
    radial-gradient(circle at 8% 8%, rgba(255, 222, 127, .18), transparent 17%),
    radial-gradient(circle at 92% 16%, rgba(255, 188, 207, .14), transparent 18%),
    rgba(255, 253, 249, 0.96);
  border: 1px solid #efe1cf;
  border-radius: 34px;
  box-shadow: 0 22px 55px rgba(91, 68, 23, .10), inset 0 1px 0 rgba(255,255,255,.9);
  overflow: visible;
}
.tool-panel::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px dashed rgba(224, 185, 103, .26);
  border-radius: 26px;
  pointer-events: none;
}

.float-sticker {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  filter: drop-shadow(0 15px 14px rgba(91, 63, 12, .16));
  transform-origin: center bottom;
}
.float-left {
  left: -28px;
  top: 210px;
  width: 130px;
  transform: rotate(-7deg);
}
.float-bottom-left {
  left: -30px;
  bottom: -68px;
  width: 165px;
  transform: rotate(-10deg);
}
.float-bottom-right {
  right: -30px;
  bottom: -66px;
  width: 148px;
  transform: rotate(9deg);
}
.float-mascot-bottom {
  right: 15%;
  bottom: -62px;
  width: 142px;
  transform: rotate(-4deg);
}

.mode-tabs,
.workspace-grid,
.results-grid,
.privacy-row {
  position: relative;
  z-index: 4;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.mode-tab {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: 20px;
  border: 2px solid #e9dfd0;
  background: linear-gradient(135deg, #fff 0%, #fffdf8 100%);
  text-align: left;
  box-shadow: 0 5px 0 rgba(226, 213, 190, .34);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.mode-tab:hover { transform: translateY(-3px) rotate(-.2deg); box-shadow: 0 9px 0 rgba(226, 213, 190, .28); }
.mode-tab.active {
  border-color: #f2be36;
  background: linear-gradient(180deg, #fff6d6 0%, #fffdf4 100%);
  box-shadow: inset 0 0 0 1px rgba(242,190,54,0.18);
}
.mode-icon {
  flex: none;
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: var(--white);
  font-size: 26px;
  box-shadow: var(--shadow-sm);
}
.mode-tab strong { display: block; font-size: 24px; margin-bottom: 4px; }
.mode-tab small { color: var(--muted); font-size: 14px; }

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(350px, 0.85fr);
  gap: 18px;
}
.card-soft,
.card-white {
  border-radius: 28px;
  box-shadow: var(--shadow-sm);
}
.card-soft {
  background: linear-gradient(145deg, #fffefb 0%, #fffaf1 100%);
  border: 1px solid #ede4d9;
  padding: 22px;
}
.card-white {
  background: linear-gradient(145deg, #fff 0%, #fffdfa 100%);
  border: 1px solid #efe7db;
}

.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head.compact { margin-bottom: 14px; }
.section-head h2 {
  margin: 0 0 4px;
  font-size: 28px;
}
.section-head p {
  margin: 0;
  color: var(--muted);
}
.optional { color: #96a0b5; font-size: .7em; }
.file-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: #335cbc;
  font-weight: 800;
  border: 1px solid #d9e4ff;
}

.editor-box {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  border: 1px solid #e7ddcf;
  border-radius: 20px;
  overflow: hidden;
  min-height: 370px;
  background: #fff;
}
.line-numbers {
  padding: 18px 8px 18px 16px;
  background: linear-gradient(180deg, #fff9ed 0%, #fffdf8 100%);
  border-right: 1px solid #f1eadf;
  color: #9aa5b8;
  font: 14px/1.72 "JetBrains Mono", monospace;
  text-align: right;
  white-space: pre;
  user-select: none;
}
#sourceText {
  width: 100%;
  min-height: 370px;
  border: 0;
  padding: 18px 20px;
  resize: vertical;
  outline: none;
  background: #fff;
  color: #34415c;
  font: 15px/1.72 "JetBrains Mono", monospace;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}
.btn {
  min-height: 58px;
  padding: 14px 18px;
  border-radius: 18px;
  border: 1px solid transparent;
  font-weight: 900;
  letter-spacing: .4px;
  transition: transform .16s ease, box-shadow .16s ease, filter .16s ease;
}
.btn:hover { transform: translateY(-2px); filter: saturate(1.06); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #ffd65d 0%, #f9c22f 100%);
  color: #322100;
  box-shadow: inset 0 -2px 0 rgba(200, 140, 0, 0.18), 0 6px 0 #e5a91d;
}
.btn-secondary {
  background: var(--white);
  color: #3770df;
  border-color: #dfe7f7;
}
.btn-light {
  background: var(--white);
  color: #e85f5f;
  border-color: #f0dde1;
}
.btn-copy {
  min-height: auto;
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--white);
  color: #406ed2;
  border: 1px solid #d8e3ff;
}

.search-group {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.search-input-wrap {
  display: flex;
  align-items: center;
  width: 100%;
  border: 1px solid #e6ddcf;
  background: var(--white);
  border-radius: 18px;
  padding: 4px;
}
#keyword {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  padding: 14px 16px;
  font-size: 15px;
}
.search-mini-btn {
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  border-radius: 14px;
  font-size: 20px;
}
.hint-badge {
  flex: none;
  padding: 10px 13px;
  border-radius: 999px;
  background: var(--yellow-soft);
  color: #976400;
  font-weight: 800;
}

.option-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
  margin: 12px 0 18px;
}
.option-grid label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #526178;
  font-weight: 700;
}
.option-grid input[type="checkbox"] {
  accent-color: var(--blue);
  width: 18px;
  height: 18px;
}
.helper-note {
  padding: 16px 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, #fff8df 0%, #fffef7 100%);
  border: 1px dashed #ecd089;
  color: #7d6841;
  line-height: 1.7;
  margin-bottom: 16px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  border-radius: 20px;
  background: var(--white);
  border: 1px solid #efe5d8;
}
.stat-icon {
  width: 60px;
  height: 60px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  font-size: 28px;
}
.stat-icon.blue { background: #edf4ff; }
.stat-icon.yellow { background: #fff3c9; }
.stat-icon.pink { background: #ffe2ea; }
.stat-icon.green { background: #e0f6ec; }
.stat-card span {
  display: block;
  color: #7e8aa0;
  font-weight: 700;
  margin-bottom: 2px;
}
.stat-card strong {
  font-size: 34px;
  line-height: 1;
}

.results-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.95fr);
  gap: 18px;
  margin-top: 18px;
}
.preview-card,
.result-card { overflow: hidden; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 22px;
  border-bottom: 1px solid #efe7dd;
  background: linear-gradient(180deg, #fffdf9 0%, #fffbf4 100%);
}
.panel-head h3 {
  margin: 0 0 4px;
  font-size: 28px;
}
.panel-head p {
  margin: 0;
  color: var(--muted);
}
.panel-head-result { justify-content: flex-start; }

.highlight-view,
.result-list {
  min-height: 440px;
  max-height: 720px;
  overflow: auto;
  padding: 18px 20px 20px;
}
.empty-state {
  display: grid;
  place-items: center;
}
.empty-box {
  width: 100%;
  padding: 36px 22px;
  text-align: center;
  color: #8f98a9;
  border: 2px dashed #efe5d9;
  border-radius: 22px;
  background: #fffdf8;
}

.code-line {
  display: grid;
  grid-template-columns: 58px 1fr;
  gap: 0;
  border-radius: 12px;
  margin-bottom: 2px;
}
.code-line.active-line {
  background: #fff6d6;
}
.code-line.match-line {
  background: #fff0ce;
}
.code-line.current-target {
  outline: 2px solid rgba(73, 132, 246, 0.33);
  background: #eef4ff;
}
.code-no {
  padding: 8px 12px 8px 0;
  text-align: right;
  color: #9ea8b9;
  border-right: 1px solid #f0e9df;
  user-select: none;
  font: 14px/1.72 "JetBrains Mono", monospace;
}
.code-text {
  padding: 8px 0 8px 16px;
  white-space: pre-wrap;
  word-break: break-word;
  font: 14px/1.72 "JetBrains Mono", monospace;
  color: #33415e;
}
mark {
  background: linear-gradient(180deg, #ffe880 0%, #ffd953 100%);
  color: #453000;
  border-radius: 6px;
  padding: 1px 3px;
  box-shadow: inset 0 -1px 0 rgba(184, 125, 0, 0.2);
}

.result-item {
  padding: 16px;
  border: 1px solid #efe4d8;
  border-radius: 20px;
  background: #fffdfa;
  margin-bottom: 12px;
  transition: .15s ease;
  cursor: pointer;
}
.result-item:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}
.result-top {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.count-pill {
  flex: none;
  min-width: 60px;
  padding: 10px 8px;
  text-align: center;
  border-radius: 16px;
  background: linear-gradient(180deg, #fff5d6 0%, #fff9ed 100%);
  border: 1px solid #f0d79d;
  color: #8d6200;
  font-weight: 900;
  line-height: 1.1;
}
.count-pill small {
  display: block;
  margin-top: 4px;
  font-size: 13px;
}
.result-content {
  min-width: 0;
  flex: 1;
}
.result-code {
  font: 14px/1.65 "JetBrains Mono", monospace;
  color: #34425d;
  margin-bottom: 6px;
  word-break: break-word;
}
.result-meta {
  color: #4f79d8;
  font-size: 14px;
  font-weight: 700;
}
.copy-inline {
  flex: none;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  border: 1px solid #e1e8f8;
  background: #fff;
  color: #4c74d2;
}

.privacy-row {
  margin: 20px auto -86px;
  width: min(720px, 80%);
  padding: 18px 20px;
  text-align: center;
  color: #6d5c4a;
  font-weight: 800;
  border: 1px solid #f0dcaa;
  border-radius: 999px;
  background: #fff8df;
  box-shadow: 0 9px 20px rgba(113, 83, 21, .09);
}

@media (prefers-reduced-motion: no-preference) {
  .float-bottom-left { animation: sticker-sway 4.8s ease-in-out infinite; }
  .float-bottom-right { animation: sticker-sway 5.4s ease-in-out -1.2s infinite reverse; }
  .float-mascot-bottom { animation: mascot-bob 3.6s ease-in-out infinite; }
}
@keyframes sticker-sway { 50% { translate: 0 -8px; } }
@keyframes mascot-bob { 50% { translate: 0 -10px; } }

@media (max-width: 1180px) {
  .hero-card,
  .workspace-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }
  .hero-left { display: none; }
  .hero-right { order: 3; }
  .float-left { display: none; }
  .float-mascot-bottom { right: 8%; }
}

@media (max-width: 760px) {
  .duplicate-container,
  .duplicate-page .crumb-row { width: calc(100% - 18px); }
  .tool-panel { padding: 16px 16px 82px; border-radius: 24px; }
  .breadcrumb-card { flex-wrap: wrap; }
  .mode-tabs,
  .action-row,
  .option-grid,
  .stats-grid { grid-template-columns: 1fr; }
  .editor-box { grid-template-columns: 42px 1fr; }
  .hero-card { padding: 18px; }
  .hero-center h1 { font-size: 34px; }
  .section-head h2,
  .panel-head h3,
  .mode-tab strong { font-size: 22px; }
  .search-group { flex-direction: column; align-items: stretch; }
  .mini-note { position: static; transform: none; margin-top: 10px; display: inline-block; }
  .float-bottom-left { left: -42px; bottom: -48px; width: 124px; }
  .float-bottom-right { right: -42px; bottom: -48px; width: 118px; }
  .float-mascot-bottom { display: none; }
  .privacy-row { width: calc(100% - 72px); margin-bottom: -65px; padding: 14px 16px; font-size: 13px; }
}
