/* Cursor / VS Code dark workbench */
:root {
  color-scheme: dark;
  --editor-bg: #1a1a1a;
  --tab-bar-bg: #252526;
  --tab-inactive-bg: #323232;
  --tab-active-bg: #1a1a1a;
  --tab-active-border: #0e8ad6;
  --title-bar-bg: #323232;
  --foreground: #e8e8e8;
  --muted: #b0b0b0;
  --border: #555555;
  --link: #58a6ff;
  --code-bg: #2b2b2b;
  --blockquote-bg: #262626;
  --welcome-panel: #262626;
  --welcome-panel-hover: #303030;
  --md-scale: 1;
  --content-max-width: 52rem;
  --font-ui: "Dana", "Segoe UI", Tahoma, sans-serif;
  --font-mono: Consolas, "Courier New", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--editor-bg);
  color: var(--foreground);
  font-family: var(--font-ui);
  line-height: 1.85;
  overflow: hidden;
}

.workbench {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.title-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0 0.75rem;
  height: 2rem;
  background: var(--title-bar-bg);
  font-size: 0.75rem;
  color: var(--muted);
  user-select: none;
}

.app-title {
  color: var(--foreground);
  font-weight: 500;
}

.privacy-hint {
  font-size: 0.7rem;
  opacity: 0.85;
}

.tabs-row {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  direction: ltr;
  background: var(--tab-bar-bg);
  border-bottom: 1px solid var(--border);
  min-height: 2.25rem;
}

.tabs {
  display: flex;
  flex: 1 1 auto;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  direction: ltr;
}

.tabs::-webkit-scrollbar {
  height: 4px;
}

.tab {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 14rem;
  padding: 0 0.65rem;
  height: 2.25rem;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--tab-inactive-bg);
  color: #c8c8c8;
  font-family: var(--font-ui);
  font-size: 0.8125rem;
  cursor: pointer;
  position: relative;
}

.tab.is-active {
  background: var(--tab-active-bg);
  color: var(--foreground);
}

.tab.is-active::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--tab-active-border);
}

.tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl;
  unicode-bidi: plaintext;
}

.tab-close {
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
  line-height: 1.15rem;
  text-align: center;
  border-radius: 0.25rem;
  font-size: 1rem;
  opacity: 0.7;
}

.tab-close:hover {
  background: rgba(255, 255, 255, 0.1);
  opacity: 1;
}

.settings-wrap {
  position: relative;
  flex: 0 0 auto;
  border-left: 1px solid var(--border);
}

.tab-action,
.tab-add {
  flex: 0 0 auto;
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--tab-bar-bg);
  color: var(--foreground);
  cursor: pointer;
  padding: 0;
}

.tab-add {
  border-right: 1px solid var(--border);
}

.tab-add {
  font-size: 1.25rem;
  line-height: 1;
}

.tab-action:hover,
.tab-add:hover {
  background: var(--tab-inactive-bg);
}

.tab-action[aria-expanded="true"] {
  background: var(--tab-inactive-bg);
  color: #fff;
}

.settings-panel[hidden] {
  display: none !important;
}

.settings-panel {
  position: absolute;
  top: 100%;
  right: 0;
  left: auto;
  z-index: 20;
  width: 15.5rem;
  margin-top: 1px;
  padding: 0.85rem 1rem 1rem;
  background: #2d2d2d;
  border: 1px solid var(--border);
  border-radius: 0 0 0.375rem 0.375rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  direction: rtl;
  text-align: right;
}

.settings-title {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--foreground);
}

.settings-field {
  display: block;
  margin-bottom: 0.85rem;
}

.settings-field:last-child {
  margin-bottom: 0;
}

.settings-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.settings-label output {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--foreground);
  direction: ltr;
}

.settings-field input[type="range"] {
  width: 100%;
  accent-color: var(--tab-active-border);
  cursor: pointer;
}

.editor-area {
  flex: 1 1 auto;
  overflow: auto;
  background: var(--editor-bg);
  position: relative;
}

.editor-area.is-dragover::after {
  content: "رها کنید تا Markdown باز شود";
  position: absolute;
  inset: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #6e6e6e;
  border-radius: 0.625rem;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.9375rem;
  pointer-events: none;
  z-index: 5;
}

.welcome[hidden] {
  display: none !important;
}

.welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(100%, calc(100vh - 4.25rem));
  padding: 2rem 1.25rem 3rem;
  direction: rtl;
}

.welcome-card {
  width: 100%;
  max-width: 22rem;
  text-align: center;
}

.welcome-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin: 0;
  padding: 2rem 1.25rem 1.75rem;
  border: 1px dashed #4a4a4a;
  border-radius: 0.625rem;
  background: var(--welcome-panel);
  color: var(--foreground);
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.welcome-drop:hover {
  background: var(--welcome-panel-hover);
  border-color: #6e6e6e;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.welcome-drop:focus-visible {
  outline: 1px solid #6e6e6e;
  outline-offset: 2px;
}

.welcome-icon {
  display: block;
  margin-bottom: 0.35rem;
  color: #9d9d9d;
}

.welcome-drop:hover .welcome-icon {
  color: #b8b8b8;
}

.welcome-drop-title {
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--foreground);
}

.welcome-drop-hint {
  font-size: 0.8125rem;
  color: var(--muted);
  line-height: 1.5;
}

.welcome-drop-ext {
  margin-top: 0.35rem;
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: #6e6e6e;
  letter-spacing: 0.02em;
}

.welcome-note {
  margin: 1rem 0 0;
  font-size: 0.75rem;
  color: #6e6e6e;
  line-height: 1.5;
}

.welcome-shortcuts {
  list-style: none;
  margin: 1.25rem 0 0;
  padding: 0.75rem 0 0;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.65rem 1rem;
}

.welcome-shortcuts li {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.welcome-shortcuts-muted {
  font-size: 0.75rem;
  color: #6e6e6e;
}

.welcome kbd {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  padding: 0.12rem 0.35rem;
  background: var(--editor-bg);
  border: 1px solid var(--border);
  border-radius: 0.2rem;
  direction: ltr;
  color: #b0b0b0;
}

.page:has(#content[hidden]) {
  display: none;
}

.page {
  max-width: var(--content-max-width);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
  font-size: calc(1rem * var(--md-scale));
}

.md-body {
  direction: rtl;
  text-align: right;
  unicode-bidi: plaintext;
}

.md-body h1,
.md-body h2,
.md-body h3,
.md-body h4 {
  line-height: 1.35;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
  font-weight: 700;
  color: var(--foreground);
}

.md-body h1 {
  font-size: 1.75rem;
  margin-top: 0;
}

.md-body h2 {
  font-size: 1.35rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
}

.md-body h3 {
  font-size: 1.12rem;
  font-weight: 500;
}

.md-body p,
.md-body ul,
.md-body ol,
.md-body blockquote {
  margin: 0.65rem 0 1rem;
}

.md-body ul,
.md-body ol {
  padding-right: 1.35rem;
  padding-left: 0;
}

.md-body li {
  margin: 0.35rem 0;
}

.md-body a {
  color: var(--link);
  text-decoration: none;
}

.md-body a:hover {
  text-decoration: underline;
}

.md-body blockquote {
  padding: 0.5rem 1rem;
  border-right: 3px solid #707070;
  border-left: none;
  background: var(--blockquote-bg);
  color: #c4c4c4;
}

.md-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.md-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.5rem;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

.md-body th,
.md-body td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.65rem;
  text-align: right;
  vertical-align: top;
}

.md-body th {
  background: var(--code-bg);
  font-weight: 600;
}

.md-body code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--code-bg);
  padding: 0.12rem 0.35rem;
  border-radius: 0.25rem;
  direction: ltr;
  unicode-bidi: embed;
  color: #e3946c;
}

.md-body pre {
  direction: ltr;
  text-align: left;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  overflow-x: auto;
  margin: 1rem 0 1.25rem;
}

.md-body pre code {
  background: none;
  padding: 0;
  font-size: 0.85rem;
  color: var(--foreground);
}

.md-body img {
  max-width: 100%;
  height: auto;
}
