:root {
  --bg: #efefe8;
  --panel: #f8f8f2;
  --tile: #ffffff;
  --text: #111111;
  --muted: #6c6c64;
  --line: #cfcfc5;
  --shadow: 0 18px 36px rgba(17, 17, 17, 0.06);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 12px;
  font-family:
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  color: var(--text);
  background: var(--bg);
}

.layout {
  width: calc(100vw - 24px);
  min-height: calc(100vh - 24px);
  padding: 28px;
  border: 2px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line);
  background: #e9e9e0;
}

.profile-copy h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.profile-copy p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.works-board {
  display: grid;
  width: 100%;
  grid-template-columns: repeat(auto-fill, 204px);
  flex: 1;
  justify-content: start;
  align-content: start;
  grid-auto-rows: 204px;
  gap: 14px;
  padding: 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  background: #f2f2ea;
}

.work-tile {
  aspect-ratio: 1 / 1;
  min-height: 204px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--tile);
  color: inherit;
  text-decoration: none;
  transition: transform 140ms ease, background 140ms ease;
}

.work-tile:hover {
  transform: translateY(-2px);
  background: #fcfcf8;
}

.work-name,
.work-link {
  display: block;
}

.work-name {
  font-size: 0.92rem;
  font-weight: 500;
  line-height: 1.2;
}

.work-link {
  color: var(--muted);
  font-size: 0.76rem;
}

.is-placeholder {
  color: #85857d;
}

.is-placeholder .work-link {
  color: #9b9b92;
}

.tool-layout {
  width: calc(100vw - 24px);
  min-height: calc(100vh - 24px);
  padding: 28px;
  border: 2px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.tool-header {
  margin-bottom: 20px;
}

.tool-header h1,
.preview-block h2,
.status-block h2 {
  margin: 0;
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1;
  letter-spacing: -0.03em;
}

.tool-header p,
.field span,
.status-block p,
.helper-list,
.inline-code,
#preview-text {
  color: var(--muted);
}

.tool-header p {
  margin: 10px 0 0;
}

.back-link {
  display: inline-block;
  margin-bottom: 14px;
  color: var(--muted);
  text-decoration: none;
}

.usage-steps {
  margin: 12px 0 10px;
  padding-left: 22px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.85;
}

.readme-link {
  display: inline-block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.84rem;
  text-decoration: none;
}

.readme-link:hover {
  color: var(--text);
}

.tool-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 16px;
}

.tool-panel {
  padding: 18px;
  border: 2px solid var(--line);
  border-radius: var(--radius-lg);
  background: #f2f2ea;
}

.field {
  display: block;
  margin-bottom: 18px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  font-size: 0.9rem;
}

.field input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.inline-code {
  display: block;
  padding: 12px 14px;
  overflow-x: auto;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 0.84rem;
}

.helper-list {
  margin: 0;
  padding-left: 18px;
  line-height: 1.7;
}

/* ── Temporary courses ───────────────────────────────────────────────────── */

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

.tc-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

/* Reuse ghost-button look at a smaller height */
.tc-add-btn {
  display: inline-flex;
  align-items: center;
  padding: 0 14px;
  height: 34px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.tc-add-btn:hover {
  background: #fcfcf8;
}

.tc-empty-hint {
  margin: 0 0 4px;
  font-size: 0.84rem;
  color: var(--muted);
}

.tc-card {
  padding: 12px;
  margin-bottom: 8px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  background: #f2f2ea;
}

.tc-row {
  display: grid;
  gap: 8px;
  margin-bottom: 8px;
}

.tc-row:last-child {
  margin-bottom: 0;
}

.tc-row-top {
  grid-template-columns: 2fr 1fr 1fr auto;
  align-items: start;
}

.tc-row-bottom {
  grid-template-columns: 1.4fr 1fr 1fr 1.4fr;
}

/* Match .field input exactly */
.tc-input,
.tc-select {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
}

.tc-input::placeholder {
  color: var(--muted);
}

/* Match ghost-button at same height as tc-input */
.tc-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  height: 42px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font: inherit;
  font-size: 0.84rem;
  cursor: pointer;
  white-space: nowrap;
}

.tc-remove:hover {
  border-color: #c9b0b0;
  color: #a33;
}

/* ── End temporary courses ───────────────────────────────────────────────── */

.tool-actions,
.download-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.action-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 2px solid var(--line);
  border-radius: 12px;
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

.action-button {
  background: #111;
  border-color: #111;
  color: #fff;
}

.ghost-button {
  background: #fff;
  color: var(--text);
}

.action-button.disabled {
  pointer-events: none;
  opacity: 0.45;
}

.status-block {
  margin-bottom: 18px;
}

.status-block p {
  margin: 10px 0 0;
}

.preview-block {
  margin-top: 18px;
}

#preview-text {
  min-height: 280px;
  margin: 12px 0 0;
  padding: 14px;
  overflow: auto;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-family:
    ui-monospace,
    SFMono-Regular,
    Menlo,
    monospace;
  font-size: 0.84rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

@media (max-width: 760px) {
  .works-board {
    grid-template-columns: repeat(auto-fill, 160px);
    grid-auto-rows: 160px;
  }

  .tool-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  body {
    padding: 8px;
  }

  .layout {
    padding: 16px;
    width: calc(100vw - 16px);
    min-height: calc(100vh - 16px);
  }

  .tool-layout {
    width: calc(100vw - 16px);
    min-height: calc(100vh - 16px);
    padding: 16px;
  }

  .profile-card {
    gap: 12px;
  }

  .avatar {
    width: 60px;
    height: 60px;
  }

  .works-board {
    width: 100%;
    grid-template-columns: repeat(auto-fill, 148px);
    grid-auto-rows: 148px;
    gap: 10px;
    padding: 12px;
  }

  .work-tile {
    min-height: 148px;
  }
}
