:root {
  --bg: #f8fafd;
  --surface: #fff;
  --surface-soft: #f1f4f9;
  --text: #202124;
  --muted: #5f6368;
  --line: #dadce0;
  --blue: #1a73e8;
  --blue-soft: #e8f0fe;
  --green: #188038;
  --yellow: #fbbc04;
  --red: #d93025;
  --shadow: 0 1px 2px rgba(60, 64, 67, .18), 0 1px 3px rgba(60, 64, 67, .12);
  font-family: Inter, "Google Sans", "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
}

[data-theme="dark"] {
  --bg: #101418;
  --surface: #171b20;
  --surface-soft: #20262d;
  --text: #e8eaed;
  --muted: #a8adb4;
  --line: #343b44;
  --blue: #8ab4f8;
  --blue-soft: #263b5f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 1px 3px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button, input, textarea, select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  color: inherit;
}

.app {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 168px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: 0;
  color: var(--text);
  text-decoration: none;
}

.brand-mark {
  display: block;
  width: 36px;
  height: 36px;
  color: var(--blue);
}

.brand-mark svg {
  display: block;
  width: 100%;
  height: 100%;
}

.brand-mark path:first-child {
  fill: color-mix(in srgb, var(--blue) 12%, transparent);
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linejoin: round;
}

.brand-mark path:last-child {
  fill: none;
  stroke: currentColor;
  stroke-width: 2.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-word {
  line-height: 1;
}

.search-wrap {
  flex: 1;
  max-width: 820px;
  position: relative;
}

.search {
  width: 100%;
  height: 46px;
  padding: 0 48px;
  border: 1px solid transparent;
  border-radius: 24px;
  outline: 0;
  background: var(--surface-soft);
  color: var(--text);
  box-shadow: var(--shadow);
}

.search:focus {
  border-color: var(--blue);
  background: var(--surface);
}

.search-icon, .kbd {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
}

.search-icon { left: 18px; }
.kbd {
  right: 14px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
}

.icon-btn {
  display: grid;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  place-items: center;
  background: transparent;
}

.icon-btn:hover { background: var(--surface-soft); }

.lang-select {
  height: 38px;
  min-width: 104px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 19px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
}

.lang-select:focus {
  border-color: var(--blue);
}

.layout {
  display: grid;
  grid-template-columns: 236px 1fr;
  gap: 26px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 26px 28px 48px;
}

.sidebar {
  position: sticky;
  top: 86px;
  align-self: start;
}

.cat-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 21px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.cat-btn:hover { background: var(--surface-soft); }
.cat-btn.active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 600;
}

.hero {
  padding: 28px 0 24px;
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(30px, 5vw, 54px);
  line-height: 1.05;
  letter-spacing: 0;
  font-weight: 600;
}

.hero p {
  max-width: 720px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.7;
}

.section-title {
  margin: 28px 0 14px;
  font-size: 18px;
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 14px;
}

.tool-card {
  display: block;
  min-height: 118px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: none;
  text-align: left;
  color: var(--text);
  text-decoration: none;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}

.tool-card:hover {
  border-color: transparent;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.tool-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

.tool-icon {
  display: grid;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  place-items: center;
  background: var(--blue-soft);
  color: var(--blue);
}

.tool-name { font-weight: 600; }
.tool-desc {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 13px;
}

.tool-view {
  display: none;
}

.tool-view.active { display: block; }

.tool-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 8px 0 20px;
}

.tool-title {
  display: flex;
  gap: 14px;
  align-items: center;
}

.tool-title h1 {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 600;
}

.tool-title p {
  margin: 0;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 48px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--line);
}

.panel-title {
  font-weight: 600;
}

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

textarea, .output, .preview {
  width: 100%;
  min-height: 360px;
  padding: 16px;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  color: var(--text);
  font-family: "Cascadia Code", Consolas, monospace;
  line-height: 1.55;
  font-size: 14px;
}

.output {
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview {
  font-family: inherit;
  overflow: auto;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0 0 16px;
  align-items: center;
}

.chip, .primary, .select, .field {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
}

.chip.active, .primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.field {
  min-width: 150px;
  outline: 0;
}

.select {
  outline: 0;
}

.dropzone {
  display: grid;
  min-height: 220px;
  place-items: center;
  margin: 0 0 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  text-align: center;
  padding: 18px;
}

.dropzone.drag {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.media-preview {
  max-width: 100%;
  max-height: 360px;
  border-radius: 8px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 60;
  transform: translateX(-50%);
  padding: 10px 16px;
  border-radius: 20px;
  background: #202124;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

.toast.show { opacity: 1; }

.empty {
  padding: 40px 0;
  color: var(--muted);
}

@media (max-width: 900px) {
  .topbar {
    flex-wrap: wrap;
    padding: 12px 16px;
  }
  .brand { min-width: auto; }
  .search-wrap {
    order: 3;
    flex-basis: 100%;
    max-width: none;
  }
  .layout {
    display: block;
    padding: 18px 16px 36px;
  }
  .sidebar {
    position: static;
    display: flex;
    overflow-x: auto;
    gap: 8px;
    padding-bottom: 12px;
  }
  .cat-btn {
    width: auto;
    flex: 0 0 auto;
  }
  .workspace {
    grid-template-columns: 1fr;
  }
}
