:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --card: #ffffff;
  --text: #162033;
  --muted: #687187;
  --line: #dce3ef;
  --accent: #1f5fff;
  --accent-hover: #184ed6;
  --danger: #bb1026;
  --success: #0f7a3f;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.page {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 16px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}

h1,
h2 {
  margin: 0 0 8px;
}

.subtitle {
  margin: 0 0 16px;
  color: var(--muted);
}

.entry-form {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

label {
  font-size: 0.95rem;
  font-weight: 600;
}

input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 1rem;
}

textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  min-height: 120px;
  resize: vertical;
  font-family: Consolas, "Courier New", monospace;
}

input:focus,
textarea:focus {
  outline: 2px solid #bdd0ff;
  border-color: var(--accent);
}

.actions {
  display: flex;
  justify-content: flex-start;
}

button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.95rem;
  cursor: pointer;
}

#submit-btn {
  background: var(--accent);
  color: #fff;
}

#submit-btn:hover {
  background: var(--accent-hover);
}

#submit-btn:disabled,
.pagination button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.form-message {
  min-height: 1.2em;
  margin: 0;
  font-size: 0.92rem;
}

.form-message.error {
  color: var(--danger);
}

.form-message.success {
  color: var(--success);
}

.table-header {
  margin-bottom: 8px;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 700px;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

th {
  background: #f8faff;
  font-weight: 700;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.muted {
  color: var(--muted);
}

.link-cell {
  word-break: break-word;
}

.copy-link {
  background: #eef3ff;
  color: #0f3da8;
  border: 1px solid #d8e4ff;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.copy-link:hover {
  color: #0a2f83;
}

.link-preview {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}

.row-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #d3dbed;
  border-radius: 6px;
  background: #f7f9ff;
  color: #12306e;
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn:hover {
  background: #e8efff;
}

.icon-btn.delete {
  color: #8f1120;
}

.edit-row-cell {
  background: #fafcff;
}

.inline-editor {
  display: grid;
  gap: 8px;
}

.inline-editor-label {
  font-size: 0.9rem;
  color: var(--muted);
}

.inline-editor-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 0.9rem;
  resize: vertical;
}

.inline-editor-actions {
  display: flex;
  gap: 8px;
}

.inline-save,
.inline-cancel {
  border: 1px solid #d3dbed;
  background: #f7f9ff;
  color: #12306e;
  padding: 6px 12px;
  border-radius: 6px;
}

.inline-save:hover,
.inline-cancel:hover {
  background: #e8efff;
}

.pagination {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.pagination button {
  background: #eef3ff;
  color: #12306e;
}

#page-indicator {
  font-size: 0.93rem;
  color: var(--muted);
  min-width: 110px;
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  background: rgba(22, 32, 51, 0.95);
  color: #fff;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (min-width: 720px) {
  .entry-form {
    grid-template-columns: 1fr 1fr auto;
    align-items: end;
    gap: 10px 12px;
  }

  .entry-form .field:nth-child(2) {
    grid-column: 1 / -1;
  }

  .entry-form .actions {
    padding-bottom: 1px;
  }

  .entry-form .form-message {
    grid-column: 1 / -1;
  }
}
