* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  max-width: 700px;
  margin: 0 auto;
  padding: 20px 1rem 40px;
  color: #1f2328;
  line-height: 1.6;
  background: #fff;
}

a { color: #0969da; text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 1.4em; margin-bottom: 0.5em; }
h2 { font-size: 1.1em; margin: 1.5em 0 0.5em; color: #656d76; }

/* Header bar */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid #d1d9e0;
  margin-bottom: 20px;
}
.header a { color: #1f2328; font-weight: 600; }
.header .auth-btn {
  font-size: 0.85em;
  padding: 4px 12px;
  border: 1px solid #d1d9e0;
  border-radius: 6px;
  background: #f6f8fa;
  color: #1f2328;
  cursor: pointer;
  text-decoration: none;
}
.header .auth-btn:hover { background: #ddf4ff; border-color: #0969da; text-decoration: none; }

/* Story cards */
.story-list { list-style: none; }
.story-card {
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}
.story-card:last-child { border-bottom: none; }
.story-card h3 { font-size: 1em; margin-bottom: 2px; }
.story-card h3 a { color: #1f2328; }
.story-card .meta { font-size: 0.8em; color: #656d76; }
.story-card .summary { font-size: 0.85em; color: #444; margin-top: 4px; }
.story-card .badges { display: inline; font-size: 0.75em; }
.story-card .badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 0.75em;
  margin-left: 4px;
}
.badge-own { background: #ddf4ff; color: #0969da; }
.badge-private { background: #f6f8fa; color: #656d76; }

/* Buttons */
.btn {
  display: inline-block;
  padding: 6px 14px;
  border: 1px solid #d1d9e0;
  border-radius: 6px;
  background: #f6f8fa;
  color: #1f2328;
  font-size: 0.85em;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn:hover { background: #ddf4ff; border-color: #0969da; text-decoration: none; }
.btn-primary { background: #0969da; color: #fff; border-color: #0969da; }
.btn-primary:hover { background: #0550ae; }
.btn-danger { color: #cf222e; border-color: #cf222e; }
.btn-danger:hover { background: #cf222e; color: #fff; }
.btn-sm { padding: 3px 8px; font-size: 0.8em; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 12px 0; }

/* Forms */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.85em; font-weight: 600; margin-bottom: 4px; }
.form-group input, .form-group textarea, .form-group select {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid #d1d9e0;
  border-radius: 6px;
  font-size: 0.9em;
  font-family: inherit;
}
.form-group textarea { min-height: 60px; resize: vertical; }
.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
  outline: none;
  border-color: #0969da;
  box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.12);
}
.form-check { display: flex; align-items: center; gap: 6px; }
.form-check input { width: auto; }

/* Modal overlay */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: #fff;
  border-radius: 10px;
  padding: 24px;
  width: 90%;
  max-width: 500px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
.modal h2 { margin: 0 0 16px; color: #1f2328; }
.modal .actions { margin-top: 16px; }

/* Collapsible sections */
details { margin: 8px 0; }
details summary {
  cursor: pointer;
  padding: 8px 0;
  font-weight: 600;
  font-size: 0.95em;
  border-bottom: 1px solid #f0f0f0;
}
details[open] summary { border-bottom-color: #d1d9e0; }
details .detail-body { padding: 8px 0 8px 12px; font-size: 0.9em; color: #444; }

/* Sortable list */
.sort-list { list-style: none; }
.sort-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
}
.sort-item .sort-btns { display: flex; gap: 4px; }
.sort-item .sort-btns button {
  padding: 2px 6px;
  border: 1px solid #d1d9e0;
  border-radius: 4px;
  background: #f6f8fa;
  cursor: pointer;
  font-size: 0.8em;
}
.sort-item .sort-btns button:hover { background: #ddf4ff; }
.sort-item .sort-label { flex: 1; }

/* Chart grid (turning point editor) */
.tp-grid { width: 100%; border-collapse: collapse; margin: 12px 0; }
.tp-grid th, .tp-grid td {
  border: 1px solid #d1d9e0;
  padding: 6px 8px;
  text-align: center;
  font-size: 0.8em;
}
.tp-grid th { background: #f6f8fa; font-weight: 600; }
.tp-grid select { padding: 2px 4px; font-size: 0.85em; border-radius: 4px; border: 1px solid #d1d9e0; }

/* Chart container */
.chart-container { margin: 16px 0; }

/* Empty state */
.empty { text-align: center; color: #656d76; padding: 40px 0; font-size: 0.95em; }

/* Back link */
.back { font-size: 0.85em; margin-bottom: 12px; display: inline-block; }
