/* ========== macOS 风格基础样式 ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-gradient-start: #f5f5f7;
  --bg-gradient-end: #e8e8ed;
  --window-bg: rgba(255, 255, 255, 0.78);
  --window-border: rgba(0, 0, 0, 0.08);
  --window-shadow: 0 30px 60px -20px rgba(0, 0, 0, 0.18),
                   0 10px 30px -15px rgba(0, 0, 0, 0.1);
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --accent-blue: #0071e3;
  --accent-blue-hover: #0077ed;
  --accent-blue-pressed: #006edb;
  --surface-1: #ffffff;
  --surface-2: #f5f5f7;
  --surface-3: #e8e8ed;
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-medium: rgba(0, 0, 0, 0.1);
  --success-green: #34c759;
  --warning-orange: #ff9500;
  --error-red: #ff3b30;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
               "Helvetica Neue", Helvetica, Arial, "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", Monaco, Inconsolata, "Fira Code", Consolas, monospace;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
}

html, body {
  height: 100%;
  font-family: var(--font-sans);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
}

body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(0, 113, 227, 0.08), transparent 60%),
    radial-gradient(1000px 500px at 110% 10%, rgba(88, 86, 214, 0.07), transparent 60%),
    linear-gradient(180deg, var(--bg-gradient-start), var(--bg-gradient-end));
  background-attachment: fixed;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* ========== 应用容器 ========== */
.app-container {
  width: min(1280px, 100%);
  height: min(880px, calc(100vh - 48px));
  background: var(--window-bg);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
  border: 1px solid var(--window-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--window-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: windowIn 0.5s var(--ease-out);
}

@keyframes windowIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ========== 头部（交通灯 + 标题） ========== */
.app-header {
  height: 52px;
  min-height: 52px;
  display: flex;
  align-items: center;
  padding: 0 18px;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(255,255,255,0.6), rgba(255,255,255,0.2));
}

.traffic-lights {
  display: flex;
  gap: 8px;
  width: 60px;
}

.light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 0.5px rgba(0,0,0,0.15);
  transition: transform 0.15s var(--ease-out), filter 0.15s;
  cursor: pointer;
}
.light:hover { transform: scale(1.12); filter: brightness(1.1); }
.light.red    { background: #ff5f57; }
.light.yellow { background: #febc2e; }
.light.green  { background: #28c840; }

.app-title {
  flex: 1;
  text-align: center;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: 0.2px;
  color: var(--text-secondary);
  user-select: none;
}

/* 顶部链接按钮 */
.header-links {
  width: auto;
  min-width: 240px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.header-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 980px;
  text-decoration: none;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.04);
  border: 1px solid transparent;
  transition: all 0.2s var(--ease-out);
  white-space: nowrap;
}

.header-link:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
  transform: translateY(-0.5px);
}

.header-link.primary {
  background: var(--accent-blue);
  color: white;
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.25);
}

.header-link.primary:hover {
  background: var(--accent-blue-hover);
  box-shadow: 0 4px 10px rgba(0, 113, 227, 0.3);
}

.header-spacer { width: 60px; }

/* ========== Tab 导航 ========== */
.tab-nav {
  display: flex;
  gap: 6px;
  padding: 14px 20px 0;
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 11px 16px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  position: relative;
}

.tab-btn:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--surface-1);
  border-color: var(--border-subtle);
  border-bottom-color: transparent;
  color: var(--accent-blue);
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.02);
}

.tab-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-3);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  transition: all 0.25s var(--ease-out);
}

.tab-btn.active .tab-icon {
  background: var(--accent-blue);
  color: white;
  transform: scale(1.05);
}

/* ========== 内容区 ========== */
.content-area {
  position: relative;
  flex: 1;
  padding: 0 20px 20px;
  overflow: hidden;
  min-height: 0;
}

.tab-panel {
  position: absolute;
  inset: 0 20px 20px 20px; /* 与 content-area padding 对应 */
  height: auto;
  display: block;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  contain: layout paint;
  transition: opacity 0.18s var(--ease-out), visibility 0.18s var(--ease-out);
  z-index: 0;
}

.tab-panel.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 1;
}

@keyframes panelIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ========== 面板卡片 ========== */
.panel-card {
  height: 100%;
  background: var(--surface-1);
  border: 1px solid var(--border-subtle);
  border-radius: 0 var(--radius-lg) var(--radius-lg) var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  padding: 22px 24px;
  gap: 18px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
}

.panel-title {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.2px;
  margin-bottom: 4px;
}

.panel-desc {
  font-size: 12.5px;
  color: var(--text-tertiary);
}

.panel-desc code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1.5px 6px;
  background: var(--surface-2);
  border-radius: 5px;
  color: var(--text-secondary);
}

.counter {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 8px 14px;
  background: var(--surface-2);
  border-radius: var(--radius-md);
  min-width: 90px;
}

.count-label {
  font-size: 10.5px;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.count-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent-blue);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  transition: transform 0.2s var(--ease-out);
}

.count-value.pulse {
  animation: pulseCount 0.3s var(--ease-out);
}

@keyframes pulseCount {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* ========== 输入输出 2 列 ========== */
.grid-2 {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  min-height: 0;
}

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

.io-block {
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 8px;
}

.io-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  padding: 0 2px;
}

.btn-group {
  display: flex;
  gap: 6px;
}

/* ========== 文本域 ========== */
.io-textarea {
  flex: 1;
  min-height: 0;
  width: 100%;
  resize: none;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--text-primary);
  background: var(--surface-2);
  transition: all 0.2s var(--ease-out);
  outline: none;
  overflow: auto;
}

.io-textarea::placeholder {
  color: #a1a1a6;
}

.io-textarea:hover {
  border-color: rgba(0, 0, 0, 0.15);
}

.io-textarea:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.1);
  background: #fff;
}

.io-textarea.output {
  background: #fafafa;
}

.io-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0 2px;
}

.line-count {
  font-size: 11.5px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}

/* ========== 按钮 ========== */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 28px;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: 980px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: 0.2px;
  cursor: pointer;
  transition: all 0.18s var(--ease-out);
  box-shadow: 0 2px 6px rgba(0, 113, 227, 0.25);
  min-width: 140px;
  user-select: none;
}

.primary-btn:hover {
  background: var(--accent-blue-hover);
  transform: translateY(-0.5px);
  box-shadow: 0 4px 12px rgba(0, 113, 227, 0.32);
}

.primary-btn:active {
  background: var(--accent-blue-pressed);
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(0, 113, 227, 0.3);
}

.primary-btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
  transform: none !important;
}

.ghost-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 11px;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
  border-radius: 7px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s var(--ease-out);
  text-transform: none;
  letter-spacing: 0;
}

.ghost-btn:hover {
  background: var(--surface-3);
  color: var(--text-primary);
  border-color: rgba(0, 0, 0, 0.15);
}

.ghost-btn:active { transform: scale(0.97); }

.ghost-btn.copied {
  background: var(--success-green);
  color: white;
  border-color: var(--success-green);
}

/* 按钮 spinner */
.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ========== 操作栏（进度 + 按钮） ========== */
.action-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 20px;
  flex-shrink: 0;
  padding-top: 4px;
}

.progress-wrap {
  flex: 1;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeSlideIn 0.3s var(--ease-out);
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.progress-bar {
  flex: 1;
  height: 8px;
  background: var(--surface-3);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-blue), #5856d6);
  border-radius: 999px;
  transition: width 0.15s linear;
  box-shadow: 0 0 10px rgba(0, 113, 227, 0.3);
}

.progress-text {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  min-width: 46px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ========== Toast 提示 ========== */
.toast-container {
  position: fixed;
  top: 32px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  background: rgba(29, 29, 31, 0.92);
  backdrop-filter: blur(20px);
  color: white;
  border-radius: 980px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  animation: toastIn 0.35s var(--ease-out), toastOut 0.3s var(--ease-in-out) 2.0s forwards;
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.toast.success::before { content: "✓"; color: #34c759; font-weight: 700; }
.toast.error   ::before { content: "✕"; color: #ff453a; font-weight: 700; }
.toast.info    ::before { content: "ℹ"; color: #0a84ff; font-weight: 700; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-12px) scale(0.96); }
}

/* ========== 滚动条（macOS 风格） ========== */
.io-textarea::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
.io-textarea::-webkit-scrollbar-track {
  background: transparent;
}
.io-textarea::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
  min-height: 24px;
}
.io-textarea::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.3);
  border: 2px solid transparent;
  background-clip: padding-box;
}
